public function getValidator()
    {
        if (!$this->validator) {
            $default_validator_class = Validator::CLASS;
            $validator_implementor = $this->getOption(self::OPTION_VALIDATOR, $default_validator_class);

            if (!class_exists($validator_implementor, true)) {
                throw new InvalidConfigException(
                    sprintf(
                        "Unable to resolve validator implementor '%s' given for attribute '%s' on entity type '%s'.",
                        $validator_implementor,
                        $this->getName(),
                        $this->getType()->getName()
                    )
                );
            }

            $validator = new $validator_implementor($this->getName(), $this->buildValidationRules());
            if (!$validator instanceof ValidatorInterface) {
                throw new InvalidTypeException(
                    sprintf(
                        "Invalid validator implementor '%s' given for attribute '%s' on entity type '%s'. " .
                        "Make sure to implement '%s'.",
                        $validator_implementor,
                        $this->getName(),
                        $this->getType() ? $this->getType()->getName() : 'undefined',
                        ValidatorInterface::CLASS
                    )
                );
            }
            $this->validator = $validator;
        }

        return $this->validator;
    }
public function getValidator()
    {
        if (!$this->validator) {
            $default_validator_class = Validator::CLASS;
            $validator_implementor = $this->getOption(self::OPTION_VALIDATOR, $default_validator_class);

            if (!class_exists($validator_implementor, true)) {
                throw new InvalidConfigException(
                    sprintf(
                        "Unable to resolve validator implementor '%s' given for attribute '%s' on entity type '%s'.",
                        $validator_implementor,
                        $this->getName(),
                        $this->getType()->getName()
                    )
                );
            }

            $validator = new $validator_implementor($this->getName(), $this->buildValidationRules());
            if (!$validator instanceof ValidatorInterface) {
                throw new InvalidTypeException(
                    sprintf(
                        "Invalid validator implementor '%s' given for attribute '%s' on entity type '%s'. " .
                        "Make sure to implement '%s'.",
                        $validator_implementor,
                        $this->getName(),
                        $this->getType() ? $this->getType()->getName() : 'undefined',
                        ValidatorInterface::CLASS
                    )
                );
            }
            $this->validator = $validator;
        }

        return $this->validator;
    }
public function getValidator ( ) { if ( ! $ this -> validator ) { $ default_validator_class = Validator :: CLASS ; $ validator_implementor = $ this -> getOption ( self :: OPTION_VALIDATOR , $ default_validator_class ) ; if ( ! class_exists ( $ validator_implementor , true ) ) { throw new InvalidConfigException ( sprintf ( "Unable to resolve validator implementor '%s' given for attribute '%s' on entity type '%s'." , $ validator_implementor , $ this -> getName ( ) , $ this -> getType ( ) -> getName ( ) ) ) ; } $ validator = new $ validator_implementor ( $ this -> getName ( ) , $ this -> buildValidationRules ( ) ) ; if ( ! $ validator instanceof ValidatorInterface ) { throw new InvalidTypeException ( sprintf ( "Invalid validator implementor '%s' given for attribute '%s' on entity type '%s'. " . "Make sure to implement '%s'." , $ validator_implementor , $ this -> getName ( ) , $ this -> getType ( ) ? $ this -> getType ( ) -> getName ( ) : 'undefined' , ValidatorInterface :: CLASS ) ) ; } $ this -> validator = $ validator ; } return $ this -> validator ; }
Returns the ValidatorInterface implementation to use when validating values for this attribute.
Override this method if you want inject your own implementation.

@return ValidatorInterface implementation
Returns the ValidatorInterface implementation to use when validating values for this attribute . Override this method if you want inject your own implementation .