PHP code example of digitalrevolution / symfony-validation-shorthand
1. Go to this page and download the library: Download digitalrevolution/symfony-validation-shorthand library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digitalrevolution / symfony-validation-shorthand example snippets
$rules = [
'name.first_name' => ':6', // last name is optional
'email' => ' 'news_letter' => '// transform the rules into a Symfony Constraint tree
$constraint = (new ConstraintFactory)->fromRuleDefinitions($rules);
// validate the data
$violations = \Symfony\Component\Validator\Validation::createValidator()->validate($data, $constraint);