PHP code example of rossriley / validation

1. Go to this page and download the library: Download rossriley/validation 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/ */

    

rossriley / validation example snippets


$validation = new \Sirius\Validation\Validator;

// add a validation rule
$validator->add('title', ');
// or use JSON
$validator->add('title', 'maxlength', '{"max": 100}');
// or a URL query string
$validator->add('title', 'maxlength', 'max=100');

// add a rule with a custom error message
$validator->add('title', 'maxlength', 'max=100', 'Article title must have less than {max} characters');

// add a rule with a custom message and a label (very handy with forms)
$validator->add('title', 'maxlength', 'max=100', '{label} must have less than {max} characters', 'Title');

// add all of rule's configuration in a string (you'll see later why it's handy')
$validator->add('title', 'maxlength(max=255)({label} must have less than {max} characters)(Title)');

// add multiple rules at once (separate using [space][pipe][space])
$validator->add('title', '