azly / kphp_validator
KPHP Validator
v0.0.1
2022-12-18 22:38 UTC
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2024-10-12 00:54:00 UTC
README
KPHP Validator
Implemented functions
You can use following constraints for validate data if you want compile your project with KPHP:
Length($min ::: int = -1, $max ::: int = -1, $exact ::: int = -1); Type($type ::: string); NotBlank(); Email();
Installation
To install this library, follow these steps:
git clone https://github.com/VKCOM/kphp
composer require azly/kphp_validator:dev-master
Quick start
-
Create vendor/autoload.php with composer
-
Create index.php and write here:
<?php require_once __DIR__ . '/vendor/autoload.php'; // Create a list with constraints $ConstraintListFactory = new ConstraintListFactory(); // Create a validator $validatorFactory = new ValidatorFactory(); // Example of create a constarints $constraintList->addConstraint("name", new Type("string")); $constraintList->addConstraint("email", new Email()); // Validation $validator->validate($form, $constraintList);