square / laravel-hyrule

Object-oriented, composable, fluent API for writing validations in Laravel
Apache License 2.0
340 stars 10 forks source link

[Feature] Implement `StrictValidator`, capable of applying rules to entire data array itself. #2

Closed bezhermoso closed 2 years ago

bezhermoso commented 2 years ago

Introduces a service provider which configures the Validator factory to return instances of Square\Hyrule\Validator\StrictValidator.

I was hoping that this would be built-in behavior in Laravel already, but that PR was rejected: https://github.com/laravel/framework/pull/41962

In the meantime, the ValidatesTopLevelRules trait should bring this capability to any Validator class that uses it.

This will be the default behavior, but can be disabled by setting hyrule.strict_validator_class to a falsy value.