PHP code example of wiltongarcia / validation
1. Go to this page and download the library: Download wiltongarcia/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/ */
wiltongarcia / validation example snippets
"resultsystems/validation": "~1.0"
composer update
'providers' => array(
...
...
ResultSystems\Validation\ValidationServiceProvider::class,
),
// Rules
$rules = array(
'cpf' => 'cpf',
'cpf_mascara' => 'cpf_mascara',
'cnpj' => 'cnpj',
'cnpj_mascara' => 'cnpj_mascara',
'cnpj_cpf' => 'cnpj_cpf',
'cnpj_cpf_mascara' => 'cnpj_cpf_mascara',
'cnpj_cpf_zero' => 'cnpj_cpf_zero',
'cnpj_cpf_zero_mascara' => 'cnpj_cpf_zero_mascara',
'telefone' => 'telefone',
'telefone_mascara' => 'telefone_mascara',
'celular' => 'celular',
'celular_mascara' => 'celular_mascara',
'hora' => 'hora',
'',
'domain' => 'domain',
'directory' => '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(
'cpf' => '22205417118',
'cpf_mascara' => '222.054.171-18',
'cnpj' => '68518321000116',
'cnpj_mascara' => '68.518.321/0001-16',
'cnpj_cpf' => '22205417118', // ou 68518321000116
'cnpj_cpf_zero' => '22205417118', // ou 68518321000116 ou 00000000000 ou 00000000000000
'cnpj_cpf_zero_mascara' => '222.054.171-18', // ou 68518321000116 ou 00000000000 ou 00000000000000
'telefone' => '3430353637',
'telefone_mascara' => '34 3035-3637',
'celular' => '4191234567',
'celular_mascara' => '41 9123-4567',
'hora' => '18:40',
'condicional' => '