public function sanitizeData($entity, $property, $value, $validations = array())
    {
        if (is_string($property)) {
            $property = $this->_description->getProperty($property);
        }

        if (empty($validations)) {
            $validations = $this->getValidations($property);
        }

        $validations = (array) AnConfig::unbox($validations);

        foreach ($validations as $validation => $options) {

            if (is_numeric($validation)) {
                $validation = $options;
                $options = array();
            }

            $method = '_sanitize'.ucfirst($validation);

            if (!method_exists($this, $method)) {
                continue;
            }

            $config = new AnConfig(array(
                'property' => $property,
                'value' => $value,
                'options' => $options,
            ));

            $value = $this->$method($config);
        }

        return $value;
    }
public function sanitizeData($entity, $property, $value, $validations = array())
    {
        if (is_string($property)) {
            $property = $this->_description->getProperty($property);
        }

        if (empty($validations)) {
            $validations = $this->getValidations($property);
        }

        $validations = (array) AnConfig::unbox($validations);

        foreach ($validations as $validation => $options) {

            if (is_numeric($validation)) {
                $validation = $options;
                $options = array();
            }

            $method = '_sanitize'.ucfirst($validation);

            if (!method_exists($this, $method)) {
                continue;
            }

            $config = new AnConfig(array(
                'property' => $property,
                'value' => $value,
                'options' => $options,
            ));

            $value = $this->$method($config);
        }

        return $value;
    }
public function sanitizeData ( $ entity , $ property , $ value , $ validations = array ( ) ) { if ( is_string ( $ property ) ) { $ property = $ this -> _description -> getProperty ( $ property ) ; } if ( empty ( $ validations ) ) { $ validations = $ this -> getValidations ( $ property ) ; } $ validations = ( array ) AnConfig :: unbox ( $ validations ) ; foreach ( $ validations as $ validation => $ options ) { if ( is_numeric ( $ validation ) ) { $ validation = $ options ; $ options = array ( ) ; } $ method = '_sanitize' . ucfirst ( $ validation ) ; if ( ! method_exists ( $ this , $ method ) ) { continue ; } $ config = new AnConfig ( array ( 'property' => $ property , 'value' => $ value , 'options' => $ options , ) ) ; $ value = $ this -> $ method ( $ config ) ; } return $ value ; }
Sanitize an entity property value against an array of passed validations.

@param AnDomainEntityAbstract $entity      Entity
@param string                 $property    Property Name
@param array                  $value       Property Value
@param array                  $validations An array of validations. If no validation are passed. Default validations are used

@return bool
Sanitize an entity property value against an array of passed validations .