PHP code example of a9korn / formio-validator

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

    

a9korn / formio-validator example snippets




namespace App;

use A9korn\FormioValidator\BaseValidator;
use A9korn\FormioValidator\IFormValidator;

class ButtonValidator extends BaseValidator implements IFormValidator
{
    protected array $     );
    }

    public function myValidator(array $component): array {
        $errors = [];

        // TODO - validation logic

        return $errors;
    }
}


    $myValidators = [
        'button' => \App\ButtonValidator::class
    ];

    $validator = new FormioBuilderValidator($schema_array['components'], $myValidators);
    $errors = $validator->validateSchema();

    $validator = new FormioBuilderValidator($schema_array['components']);
    $validator->registerValidator('button',\App\ButtonValidator::class);



use A9korn\FormioValidator\FormioBuilderValidator;

ma-test.json');
$schema_array = json_decode($schema, true);

try {
    $validator = new FormioBuilderValidator($schema_array['components']);
    $errors = $validator->validateSchema();

    print_r($errors);
} catch (Exception $e) {
    print_r($e);
}