PHP code example of sfw2 / validator

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

    

sfw2 / validator example snippets


    use SFW2\Validator\Ruleset;

    $rulset = new Ruleset();


    use SFW2\Validator\Validators\IsNotEmpty;

    $rulset->addNewRules('home', new IsNotEmpty());

    use SFW2\Validator\Validators\IsNotEmpty;
    use SFW2\Validator\Validators\IsTime;

    $rulset->addNewRules('startTime', new IsNotEmpty(), new IsTime());

    use SFW2\Validator\Validator;

    $validator = new Validator($rulset);
    $values = [];

    $error = $validator->validate($_POST, $values);