jfernando / php-validate
A Java Bean Validation based for PHP
Installs: 687
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Open Issues: 0
pkg:composer/jfernando/php-validate
Requires
Requires (Dev)
- phpmd/phpmd: @stable
- phpmetrics/phpmetrics: ^1.10
- phpunit/phpunit: ^5.6
- sebastian/phpcpd: *
- squizlabs/php_codesniffer: *
This package is not auto-updated.
Last update: 2020-08-21 20:51:13 UTC
README
A set of tools for validations with PHP.
Introduction
This library offers tools for validations of many kinds of problem:
ValidatorVerifierA set of tools for object validations based in annotations, having inspiration in Java Beans ValidationsTransformationA object transformation based in annotationsMapValidateA simple set of tools for validate associative arraySchemaA set of tools for validate associative array, schema based, inspirated in hapijs/joi
ValidatorVerifier
Transformation
MapValidate
Schema
$schema = Schema::schema([ 'name' => Schema::string()->min(3)->max(80), 'address' => Schema::schema([ 'street' => Schema::string()->min(3)->max(50) 'number' => Schema::numeric(['code' => 'invalid_number', 'message' => 'Invalid number']), 'other' => Schema::string()->required(false) // Optional field ]), 'projects' => Schema::array()->schema([ 'name' => Schema::string() ]) ]); $errors = $schema->getErrors($data); $errors->isValid(); // true | false $errors->getErrors(); //
This library is expansive for use custom validations