zendframework/zend-validator
Powerful validation library from Zend Framework for PHP apps. Provides a wide range of reusable validators, input filtering, and custom rule support with clear error messages. Integrates easily into forms and domain validation workflows.
composer require zendframework/zend-validatorStringLength, Digits, EmailAddress, or RegexisValid($value) to trigger validation; errors are retrieved via getMessages() or getMessagesByField()AggregateValidator or Chain:
$validator = new Chain([
new StringLength(['min' => 8]),
new Regex(['pattern' => '/[A-Z]/']),
]);
RegistrationValidator, ApiCreateUserValidator) using factory or service patterns for reusability and testingsetObject() and set Groups() (via ValidationGroupTrait in laminas-validator) for context-aware validation in CRUD operationsgetMessages() on failureUniqueUsername extending AbstractValidator) to keep validation logic testable and decoupled'%value%'; use setOption('messages', [...]) or override getMessages() to customize wording or translate using Zend\I18n\TranslatorFile\Upload and File\Size validators require $_FILES to be processed before validation; remember to call isValid() after move_uploaded_file()Chain, use Chain::OR_BREAK or Chain::AND_CHAIN to control short-circuit behavior; test edge cases like empty vs. null inputsValidatorInterface or extend AbstractValidator — cache custom validators in production if used in hot paths (e.g., with PSR-6/16)setOptions(['db' => $db]))setContext()) — powerful for validating fields depending on others (e.g., Date validator checking start_date < end_date)How can I help you explore Laravel packages today?