PHP code example of wemersonrv / laravel-custom-rules

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

    

wemersonrv / laravel-custom-rules example snippets


$rules = [
    'cpf' => 'cnpj',
    'cellphone' => 'mobile_br',
    'landline' => 'landline_br',
    'postal_code' => 'cep',
    'mac' => 'NPJ.',
    'mobile_br' => 'Invalid mobile number.', // The show is yours, do as you want!
    'landline_br' => 'Invalid landline number.',
    'cep' => 'The :attribute must be a valid Brazilian ZIP Code (CEP).',
    'mac_address' => 'The :attribute must be a valid MAC address',
];

$validator = \Validator::make($request->all(), $rules, $errorMsgs);
if($validator->fails()){
    return response($validator->errors(), 400);
}