PHP code example of suomec / ovalidator

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

    

suomec / ovalidator example snippets



$form = (new Form())->fromArray([
    'field_1' => 'any value',
    'field_2' => 15,
]);


class Input
{
    public int $field_2;
}

$input = new Input();


$config = (new Config())
    ->add('field_2', 'Some description', State::Required, [
        new VInteger(),
        new VMin(10),
        new VMax(20),
    ])
;



$result = (new Mapper($form, $config))->toObject($input, new ReflectionSetter());