public static function validation($modelType, $propertyName, $callback, $errorMessage = null) {
        if (!self::canAnnotate($modelType)) {
            return;
        }

        if (empty($propertyName)) {
            throw new \Exception('$propertyName must not be empty.');
        }

        if (!is_callable($callback)) {
            throw new \Exception('A function is expected.');
        }

        self::makeDataAnnotation($propertyName);

        self::$annotations[$propertyName]->customValidation = array($callback, $errorMessage);
    }
public static function validation($modelType, $propertyName, $callback, $errorMessage = null) {
        if (!self::canAnnotate($modelType)) {
            return;
        }

        if (empty($propertyName)) {
            throw new \Exception('$propertyName must not be empty.');
        }

        if (!is_callable($callback)) {
            throw new \Exception('A function is expected.');
        }

        self::makeDataAnnotation($propertyName);

        self::$annotations[$propertyName]->customValidation = array($callback, $errorMessage);
    }
public static function validation ( $ modelType , $ propertyName , $ callback , $ errorMessage = null ) { if ( ! self :: canAnnotate ( $ modelType ) ) { return ; } if ( empty ( $ propertyName ) ) { throw new \ Exception ( '$propertyName must not be empty.' ) ; } if ( ! is_callable ( $ callback ) ) { throw new \ Exception ( 'A function is expected.' ) ; } self :: makeDataAnnotation ( $ propertyName ) ; self :: $ annotations [ $ propertyName ] -> customValidation = array ( $ callback , $ errorMessage ) ; }
Specifies a custom validation method that is used to validate the property.

@param string|object $modelType The name type of model.
@param string $propertyName The property name to check.
@param callback $callback Function to valid the value.
The function takes a value of the property and must return true,
if successful, or false if the value is incorrect.
@param string The error message.

@return void
Specifies a custom validation method that is used to validate the property .