PHP code example of seymenkonuk / validator

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

    

seymenkonuk / validator example snippets


$validator = new Validator(new Translator(
    new FileLoader(),
    "tr",
));

$validator = new Validator(new Translator(
    new FileLoader(__DIR__ . "/lang"),
    "tr",
));

return [
    " "Bu alan metin olmalıdır.",
    "email" => "Bu alan geçerli bir e-posta olmalıdır.",
    'min' => 'Bu alan en az {value} olmalıdır!',
    // ve daha fazlası...
];

$schema = $validator->object()->schema([
    "username" => $validator->field()
        ->string()
        ->min(2)
        ->max(10)
        ->ue()
        ->

$result = $schema->validate([
    "username" => "seymenkonuk",
    "email" => "[email protected]",
    "is_agreed" => true,
]);

if ($result->passed()) {
    var_dump($result->validated());
} else {
    var_dump($result->errors());
}

$schema = $validator->object()->schema([
    "parent" => $validator->object()->schema([
        "name" => $validator->field()->string()->

$schema = $validator->object()->schema([
    "hobbies" => $validator->array()
        ->items($validator->field()->string())
        ->minItems(0)
        ->maxItems(10)
        ->default([]),
]);