PHP code example of yuri-oliveira / validate

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

    

yuri-oliveira / validate example snippets


$validate->validate([
    'email' => ['condition:filled', 'email']
    'password' => ['condition:empty', '



use YuriOliveira\Validate\Condition;

, $key) {
    return is_string($value) ? true : false;
});


return [
    '> 'O campo :attribute deve conter um email válido.',
    'max' => [
        'string' => 'O campo :attribute deve conter no máximo :max caracteres.',
        'file' => 'O arquivo :attribute deve ter o tamanho máximo de :max.'
    ]
];




use YuriOliveira\Validate\Message\Message;

ribute é customizado'
];

Message::extend($customMessages);



Message::get('O campo email é obrigatório.

Message::get('max.string', 'password', 25);
// resultado: O campo password deve conter no máximo 25 caracteres.



Validate::extend('custom', function($key, $value) {

    if (!is_string($value)) {

        return Message::get('custom', $key);
    }

    return true;
});