Skip to content

Issue with HTML Input for Floating-Point Annotated value #1092

Open
@torkashvand

Description

@torkashvand

What happened?

The HTML type="number" input strips the decimal point from our float type (for example: longitude coordinates), leading to incorrect data handling for floating-point numbers.

Steps to Reproduce:

define an annotated field

def validate_longitude(v: float) -> float:
     return v

LongitudeCoordinate = Annotated[
    float,
    AfterValidator(validate_longitude),
    Doc(
        "A longitude coordinate, modeled as a string. "
        "The coordinate must match the format conforming to the longitude "
        "range of -180 to +180 degrees. It can be a floating-point number or an integer. "
        "Valid examples: 40.7128, -74.0060, 180, -180, 0."
    ),
]

then in the generated HTML form enter a floating-point number in the longitude input field.
Observe that the decimal point is removed or rounded.

Expected Behavior:
Users should be able to input longitude coordinates with decimal precision.

Version

2.2.1

What python version are you seeing the problem on?

Python 3.12

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwaiting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions