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

Feature request: validation rules #92

Closed
aricooperdavis opened this issue May 22, 2023 · 3 comments
Closed

Feature request: validation rules #92

aricooperdavis opened this issue May 22, 2023 · 3 comments
Labels
good first issue Good for newcomers

Comments

@aricooperdavis
Copy link

It would be quite nice to include validation rules that could be used in form validations to validate appropriate JSON representations of each class.

For example, we could then validate requests using:

use MatanYadaev\EloquentSpatial\Rules\Point;
 
$request->validate([
    'location' => ['required', new Point],
]);

rather than having to do it manually, such as:

$request->validate([
    'location' => ['required', 'array:type,coordinates'],
    'location.type' => ['required', 'in:Point'],
    'location.coordinates' => ['required', 'array:0,1'],
    'location.coordinates.0' => ['required', 'numeric', 'min:-90', 'max:90'],
    'location.coordinates.1' => ['required', 'numeric', 'min:-180', 'max:180'],
]);

Unless I'm being a bit thick and can do it more easily than this?

@MatanYadaev
Copy link
Owner

Hi @aricooperdavis, sounds cool. Can you submit a PR?

@MatanYadaev MatanYadaev added the good first issue Good for newcomers label May 22, 2023
@aricooperdavis
Copy link
Author

Actually, perhaps this is out of scope for this package, as it's already implemented here: https://github.com/yucadoo/laravel-geojson-rule ?

@MatanYadaev
Copy link
Owner

@aricooperdavis It is kind of out of scope for this package, because it is focused on Eloquent. But I'm open to new ideas. Thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants