Skip to content

[Validator] add new constraints Latitude and Longitude #61312

@zairigimad

Description

@zairigimad

Description

When working with coordinates, it's common to validate their format using regular expressions. While this approach works well, we often end up duplicating the same regex across different parts of the codebase—whether for API validation, form validation, or elsewhere.

This leads to repetition. It would be much cleaner and more maintainable to have this logic centralized in a dedicated constraint class.

examples

class LongitudeDummy
{
    #[Longitude]
    private $a;

    #[Longitude(message: 'myMessage')]
    private $b;

    #[Longitude(groups: ['my_group'])]
    private $c;
}
class LatitudeDummy
{
    #[Latitude]
    private $a;

    #[Latitude(message: 'myMessage')]
    private $b;

    #[Latitude(groups: ['my_group'])]
    private $c;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions