dhii / validation-interface
A base interface for validators
Installs: 95 960
Dependents: 9
Suggesters: 1
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^7.1 | ^8.0
Requires (Dev)
- phpunit/phpunit: ^7.0 | ^8.0 | ^9.0
- slevomat/coding-standard: ^6.0
- symfony/polyfill-mbstring: 1.20
- symfony/polyfill-php80: ^1.19
- vimeo/psalm: ^3.11.7 | ^4.0
This package is auto-updated.
Last update: 2024-12-15 00:40:12 UTC
README
Simple interface for most basic validator implementations.
Details
This package aims to standardize validators, so as to make consuming code compatible with a wide variety of validator implementations. Validation is such a common task that being able to validate in an interoperable way is extremely useful. Interfaces in this package aim to fix that by providing a common validation entry point on one side, and standards-compliant validation error exceptions on the other. This allow developers to take advantage of exception "bubbling" and handle validation errors where they think best, as well as to retrieve a list of human-readable validation error messages without knowledge of the validator internals, or prior reference to the validator object. Also, reporting validation failure as an exception is very convenient for cases where it is only possible to continue if a validation subject is valid.
Interfaces
ValidatorInterface
- The central interface of the standard. Provides validation entry point (trigger) asvalidate()
. Validators MUST implement this interface.ValidationFailedExceptionInterface
- Occurs when subject fails validation, and reports the failed subject, and the validator that validated the subject, as well as a list of validation error messages.ValidationExceptionInterface
- Represents an error related to a validator.