Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for GpsPoint is missing #69

Open
FabianKoestring opened this issue Sep 10, 2020 · 1 comment
Open

Documentation for GpsPoint is missing #69

FabianKoestring opened this issue Sep 10, 2020 · 1 comment
Labels
Bug Something isn't working Documentation

Comments

@FabianKoestring
Copy link
Contributor

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

It seems like the Documentation for Laminas\Validator\GpsPoint is missing. I never knew that there is a validator for this. 🤯

@froschdesign froschdesign added Bug Something isn't working Documentation labels Sep 10, 2020
@ajgale
Copy link

ajgale commented Jun 21, 2022

I believe this validator should either be rewritten or removed entirely as it will return true for the input "foo, bar"

It expects a string as input in the form "latitude, longitude" :

    public function isValid($value)
    {
        if (strpos($value, ',') === false) {
            $this->error(self::INCOMPLETE_COORDINATE, $value);
            return false;
        }

        [$lat, $long] = explode(',', $value);

but the isValidCoordinate() method blindly casts the supposed lat or long to a double:

        $doubleLatitude = (double) $value;

        if ($doubleLatitude <= $maxBoundary && $doubleLatitude >= $maxBoundary * -1) {
            return true;
        }

which results in a 0 value in the case of non-numerical strings, which then passes validation as a valid lat/long.

At the very least it should have explicit comments stating that the expected input is in a very particular format already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Documentation
Projects
None yet
Development

No branches or pull requests

3 participants