public static function quickValidate(?string $value, array $constraints = [])
    {
        // Initialize the validator
        $validator = new static('quickValidate function', InputFieldTypes::PASSED, [], $value, null);
        // Add the constraints
        if (is_array($constraints) && count($constraints) > 0) {
            foreach ($constraints as $constraint) {
                /** @var Constraint|array $constraint */
                if (is_array($constraint) && count($constraint) > 0) {
                    $validator->addConstraint(Constraint::factory($constraint));
                } elseif (!is_array($constraint)) {
                    $validator->addConstraint($constraint);
                }
            }
        }
        // Return the value or throw an exception
        if ($validator->isValid()) {
            return $validator->getValue();
        } else {
            throw new InvalidInputException('The value is not valid.');
        }

    }
public static function quickValidate(?string $value, array $constraints = [])
    {
        // Initialize the validator
        $validator = new static('quickValidate function', InputFieldTypes::PASSED, [], $value, null);
        // Add the constraints
        if (is_array($constraints) && count($constraints) > 0) {
            foreach ($constraints as $constraint) {
                /** @var Constraint|array $constraint */
                if (is_array($constraint) && count($constraint) > 0) {
                    $validator->addConstraint(Constraint::factory($constraint));
                } elseif (!is_array($constraint)) {
                    $validator->addConstraint($constraint);
                }
            }
        }
        // Return the value or throw an exception
        if ($validator->isValid()) {
            return $validator->getValue();
        } else {
            throw new InvalidInputException('The value is not valid.');
        }

    }
public static function quickValidate ( ? string $ value , array $ constraints = [ ] ) { // Initialize the validator $ validator = new static ( 'quickValidate function' , InputFieldTypes :: PASSED , [ ] , $ value , null ) ; // Add the constraints if ( is_array ( $ constraints ) && count ( $ constraints ) > 0 ) { foreach ( $ constraints as $ constraint ) { /** @var Constraint|array $constraint */ if ( is_array ( $ constraint ) && count ( $ constraint ) > 0 ) { $ validator -> addConstraint ( Constraint :: factory ( $ constraint ) ) ; } elseif ( ! is_array ( $ constraint ) ) { $ validator -> addConstraint ( $ constraint ) ; } } } // Return the value or throw an exception if ( $ validator -> isValid ( ) ) { return $ validator -> getValue ( ) ; } else { throw new InvalidInputException ( 'The value is not valid.' ) ; } }
Validates input as a one-off. Allows quick and dirty validation. Returns null if the value is not valid.

TODO: Decide should this just return true/false if the value is/not valid?

@param string $value The value to test
@param array $constraints The definition of the constraints
@return mixed The value if valid
@throws InvalidInputException If the value is not valid
Validates input as a one - off . Allows quick and dirty validation . Returns null if the value is not valid .