PHP code example of resultsystems / validation

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

    

resultsystems / validation example snippets


composer 

'providers' => array(
    ...
    ...
    ResultSystems\Validation\ValidationServiceProvider::class,
),

// Rules
$rules = array(
    'nis'                   => 'nis',
    'titulo_eleitoral'      => 'titulo_eleitoral',
    'cpf'                   => 'cpf',
    'cpf_mask'              => 'cpf_mask',
    'cnpj'                  => 'cnpj',
    'cnpj_mask'             => 'cnpj_mask',
    'cnpj_cpf'              => 'cnpj_cpf',
    'cnpj_cpf_mask'         => 'cnpj_cpf_mask',
    'telefone'              => 'telefone',
    'telefone_mask'         => 'telefone_mask',
    'celular'               => 'celular',
    'celular_mask'          => 'celular_mask',
    'time'                  => 'time',
    'min_time'              => 'min_time',
    'after_time'            => 'after_time',
    ''             => 'directory',
    'FileExists'            => 'FileExists',
    'isFile'                => 'file',
    'endsWith'              => 'endsWith:banana',
    'equals'                => 'equals:banana',
    'even'                  => 'even',
    'float'                 => 'float',
    'graph'                 => 'graph',
    'instance'              => 'instance:DateTime',
    'int'                   => 'int',
    'json'                  => 'json',
    'leapDate'              => 'leapDate:Y-m-d',
    'leapYear'              => 'leapYear',
    'arr'                   => 'arr',
    'lowercase'             => 'lowercase',
    'macAddress'            => 'macAddress',
    'multiple'              => 'multiple:3',
    'negative'              => 'negative',
    'noWhitespace'          => 'noWhitespace',
    'notArray'              => 'arr|not',
    'nullValue'             => 'nullValue',
    'numeric'               => 'numeric',
    'object'                => 'object',
    'odd'                   => 'odd',
    'perfectSquare'         => 'perfectSquare',
    'positive'              => 'positive',
    'primeNumber'           => 'primeNumber',
    'punct'                 => 'punct',
    'readable'              => 'readable',
    'regex'                 => 'regex:/5/',
    'roman'                 => 'roman',
    'slug'                  => 'slug',
    'space'                 => 'space:b',
    'tld'                   => 'tld', // Top Level Domain,
    //'uploaded'            => 'uploaded',
    'uppercase'             => 'uppercase',
    'version'               => 'version',
    'xdigit'                => 'xdigit', // Hexadecimal
    'writable'              => 'writable',
    'alwaysValid'           => 'alwaysValid',
    'bool'                  => 'bool'
);

// Data
$data = array(
    'nis'                   => '17033259504',
    'titulo_eleitoral'      => '000000000000',
    'cpf'                   => '22205417118',
    'cpf_mask'           => '222.054.171-18',
    'cnpj'                  => '68518321000116',
    'cnpj_mask'          => '68.518.321/0001-16',
    'cnpj_cpf'              => '22205417118', // ou 68518321000116
    'telefone'              => '3430353637',
    'telefone_mascara'      => '34 3035-3637',
    'celular'               => '4191234567',
    'celular_mascara'       => '41 9123-4567',
    'time'                  => '18:40',
    'min_time'              => 'min_time:time',
    'after_time'            => 'after_time:time',
    'condicional'           => '