You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Application-Web/src/Validation/Validator.php

24 lines
673 B

<?php
namespace App\Validation;
abstract class Validator {
/**
* validates a variable string
* @param string $name the name of the tested value
* @param mixed $val the value to validate
* @return ValidationFail[] the errors the validator has reported
*/
abstract public function validate(string $name, $val): array;
/**
* Creates a validator composed of this validator, and given validator
* @param Validator $other the second validator to chain with
* @return Validator a composed validator
*/
public function then(Validator $other): Validator {
return new ComposedValidator($this, $other);
}
}