src/Callbacks/RegexValidatorCallback.php
/**
     * Will be invoked by a observer it has been registered for.
     *
     * @param string|null $attributeCode  The code of the attribute that has to be validated
     * @param string|null $attributeValue The attribute value to be validated
     *
     * @return mixed The modified value
     */
Will be invoked by a observer it has been registered for.
@param string|null $attributeCode  The code of the attribute that has to be validated
@param string|null $attributeValue The attribute value to be validated

@return mixed The modified value
Will be invoked by a observer it has been registered for . @param string|null $attributeCode The code of the attribute that has to be validated @param string|null $attributeValue The attribute value to be validated @return mixed The modified value
public function handle($attributeCode = null, $attributeValue = null)
    {
        $validations = $this->getValidations($attributeCode);
        if (sizeof($validations) === 0) {
            throw new \InvalidArgumentException(
                sprintf('Missing configuration value for custom validation of attribute "%s"', $attributeCode)
            );
        }
        foreach ($validations as $pattern) {
            if (preg_match($pattern, $attributeValue)) {
                continue;
            }
            throw new \InvalidArgumentException(
                sprintf(
                    'Found invalid value "%s" for column "%s" (must match pattern: "%s")',
                    $attributeValue,
                    $attributeCode,
                    $pattern
                )
            );
        }
    }
public function handle ( $ attributeCode = null , $ attributeValue = null ) { $ validations = $ this -> getValidations ( $ attributeCode ) ; if ( sizeof ( $ validations ) === 0 ) { throw new \ InvalidArgumentException ( sprintf ( 'Missing configuration value for custom validation of attribute "%s"' , $ attributeCode ) ) ; } foreach ( $ validations as $ pattern ) { if ( preg_match ( $ pattern , $ attributeValue ) ) { continue ; } throw new \ InvalidArgumentException ( sprintf ( 'Found invalid value "%s" for column "%s" (must match pattern: "%s")' , $ attributeValue , $ attributeCode , $ pattern ) ) ; } }
Will be invoked by a observer it has been registered for.
Will be invoked by a observer it has been registered for .
// the validations for the attribute with the given code // throw an exception if NO allowed values have been configured // if the passed value is in the array, return immediately // validates the attribute value against the passed patterns // throw an exception if the value is NOT in the array