public function cleanFields($exclude = [])
    {
        $errors = [];

        /** @var $field Field */
        foreach ($this->getMeta()->getConcreteFields() as $field) {
            if (in_array($field->getName(), $exclude)) {
                continue;
            }
            $value = $this->{$field->getAttrName()};
            // Skip validation for empty fields with blank=True. The developer
            // is responsible for making sure they have a valid value.
            if ($field->formBlank && empty($value)) {
                continue;
            }

            try {
                $this->{$field->getAttrName()} = $field->clean($this, $value);
            } catch (ValidationError $error) {
                $errors[$field->getName()] = $error->getErrorList();
            }
        }

        if (!empty($errors)) {
            throw new ValidationError($errors);
        }
    }
public function cleanFields($exclude = [])
    {
        $errors = [];

        /** @var $field Field */
        foreach ($this->getMeta()->getConcreteFields() as $field) {
            if (in_array($field->getName(), $exclude)) {
                continue;
            }
            $value = $this->{$field->getAttrName()};
            // Skip validation for empty fields with blank=True. The developer
            // is responsible for making sure they have a valid value.
            if ($field->formBlank && empty($value)) {
                continue;
            }

            try {
                $this->{$field->getAttrName()} = $field->clean($this, $value);
            } catch (ValidationError $error) {
                $errors[$field->getName()] = $error->getErrorList();
            }
        }

        if (!empty($errors)) {
            throw new ValidationError($errors);
        }
    }
public function cleanFields ( $ exclude = [ ] ) { $ errors = [ ] ; /** @var $field Field */ foreach ( $ this -> getMeta ( ) -> getConcreteFields ( ) as $ field ) { if ( in_array ( $ field -> getName ( ) , $ exclude ) ) { continue ; } $ value = $ this -> { $ field -> getAttrName ( ) } ; // Skip validation for empty fields with blank=True. The developer // is responsible for making sure they have a valid value. if ( $ field -> formBlank && empty ( $ value ) ) { continue ; } try { $ this -> { $ field -> getAttrName ( ) } = $ field -> clean ( $ this , $ value ) ; } catch ( ValidationError $ error ) { $ errors [ $ field -> getName ( ) ] = $ error -> getErrorList ( ) ; } } if ( ! empty ( $ errors ) ) { throw new ValidationError ( $ errors ) ; } }
Cleans all fields and throw a ValidationError containing an associtive array of all validation errors if any
occur.

@param array $exclude

@throws ValidationError
@author: Eddilbert Macharia (http://eddmash.com)<edd.cowan@gmail.com>
Cleans all fields and throw a ValidationError containing an associtive array of all validation errors if any occur .