Validates the object and all objects related to this table.

@see        getValidationFailures()
@param      object $validator A Validator class instance
@return     boolean Whether all objects pass validation.
322219
public function validate(Validator $validator = null)
    {
        if (null === $validator) {
            $validator = new Validator(new ClassMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory(), new DefaultTranslator());
        }

        $failureMap = new ConstraintViolationList();

        if (!$this->alreadyInValidation) {
            $this->alreadyInValidation = true;
            $retval = null;


            $retval = $validator->validate($this);
            if (count($retval) > 0) {
                $failureMap->addAll($retval);
            }

            if (null !== $this->collAttributeAttributeTypes) {
                foreach ($this->collAttributeAttributeTypes as $referrerFK) {
                    if (method_exists($referrerFK, 'validate')) {
                        if (!$referrerFK->validate($validator)) {
                            $failureMap->addAll($referrerFK->getValidationFailures());
                        }
                    }
                }
            }
            if (null !== $this->collAttributeTypeI18ns) {
                foreach ($this->collAttributeTypeI18ns as $referrerFK) {
                    if (method_exists($referrerFK, 'validate')) {
                        if (!$referrerFK->validate($validator)) {
                            $failureMap->addAll($referrerFK->getValidationFailures());
                        }
                    }
                }
            }

            $this->alreadyInValidation = false;
        }

        $this->validationFailures = $failureMap;

        return (Boolean) (!(count($this->validationFailures) > 0));

    }
1340806
public function addValidator(Validator\ValidatorInterface $validator) {
        $this->validators[get_class($validator)] = $validator;
        
        return $this;
    }
73286
protected function registerValidationRules($validator)
    {
        /**
         * elfinder validator
         */
        $validator->resolver(function($translator, $data, $rules, $messages)
        {
            return new BaseValidator($translator, $data, $rules, $messages);
        });
        $validator->replacer('elfinder_max', function($message, $attribute, $rule, $parameters) {
            return str_replace(':size',$parameters[0],$message);
        });
        $validator->replacer('elfinder', function($message, $attribute, $rule, $parameters) {
            return str_replace(':values',implode(', ', $parameters),$message);
        });

    }
1138976
public function setValidator($validator)
    {
        $this->clearCache();
        $this->validators = [];
        $this->addValidator($validator);

        return $this;
    }
992987
public function validate($validator)
    {
        // First check if value is numeric
        if ($this->value && $this->isNumeric()) {
            // Convert to a number to check
            $value = $this->value + 0;
            
            if(is_int($value)) {
                return true;
            }
        }
        
        $validator->validationError(
            $this->name,
            _t(
                'Checkout.VALIDATION', '{value} is not a valid number, only whole numbers can be accepted for this field',
                array('value' => $this->value)
            ),
            "validation"
        );
        return false;
    }
1144674
public function validate($validator)
    {
        $maxFiles = $this->getAllowedMaxFileNumber();
        $count = count($this->getItems());

        if ($maxFiles < 1 || $count <= $maxFiles) {
            return true;
        }

        $validator->validationError($this->getName(), _t(
            __CLASS__ . '.ErrorMaxFilesReached',
            'You can only upload {count} file.|You can only upload {count} files.',
            [
                'count' => $maxFiles,
            ]
        ));

        return false;
    }
35557
public function validationDefault(Validator $validator) {
        $validator
                ->add('id', 'valid', ['rule' => 'numeric'])
                ->allowEmpty('id', 'create')
                ->add('sys_user', 'valid', ['rule' => 'numeric'])
                ->allowEmpty('sys_user')
                ->add('sys_role', 'valid', ['rule' => 'numeric'])
                ->allowEmpty('sys_role')
                ->add('allow', 'valid', ['rule' => 'boolean'])
                ->allowEmpty('allow');

        return $validator;
    }
366716
public static function isValid($validator, $value)
    {
        /** @var ValidatorInterface $validator */
        $validator = static::create($validator);
        $result = $validator->isValid($value);
        static::$_messages = $validator->getMessages();
        return $result;
    }
1158687
public function setValidator(Validator $validator)
    {
        $this->validator = $validator;
        
        $validator->configureRule($this);
        
        return $this;
    }
365749
protected function _setValidator($validator)
    {
        if (!is_null($validator) && !($validator instanceof ValidatorInterface)) {
            throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator);
        }

        $this->validator = $validator;
    }
715111
public function validate($validator)
    {
        // Check Value and Timestamp:
        
        if (!empty($this->value) || $this->tooSoon()) {
            
            // Define Validation Error:
            
            $validator->validationError(
                $this->name,
                _t(
                    __CLASS__ . '.VALIDATIONERROR',
                    'Sorry, an error has occurred. Please try again later.'
                ),
                'validation'
            );
            
            // Answer Failure:
            
            return false;
            
        }
        
        // Answer Success:
        
        return true;
    }
1202754
public function validate(Validator $validator)
    {
        $handler = $this->get('metadata')->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->validate($this, $validator);
        }
    }
233143
public function validationPasswordReset(Validator $validator) {
		return $this->validateOldPassword($validator)
			->validatePassword($validator)
			->validateConfirmPassword($validator);
	}
351936
public function validate(Validator $validator, $object, $forScenario)
    {
        if (!is_numeric($object)) {
            return false;
        }

        if ($this->min !== null) {
            if ($object < $this->min) {
                return false;
            }
        }
        if ($this->max !== null) {
            if ($object > $this->max) {
                return false;
            }
        }

        return true;
    }
878452
public function setValidators($validators = [])
    {
        if (is_array($validators)) {
            $this->validators = $validators;
        } else {
            $this->validators = func_get_args();
            if (count($this->validators) == 1 && is_string($this->validators[0])) {
                $this->validators = explode(',', $this->validators[0]);
            }
        }

        if (in_array('required', $this->validators)) {
            $this->setRequired();
            unset($this->validators[array_search('required', $this->validators)]);
        }


        return $this;

    }
667716
public function validate($validator)
    {
        if ($this->checkHostname($this->Value())) {
            return true;
        }

        $validator->validationError(
            $this->getName(),
            _t('DomainNameField.INVALID_DOMAIN', 'Invalid domain name'),
            'validation'
        );
        return false;
    }
337711
public function validationDefault(Validator $validator)
    {
        $validator
            ->notEmpty('handler', __d('field', 'Invalid field type.'))
            ->add('label', [
                'notBlank' => [
                    'rule' => 'notBlank',
                    'message' => __d('field', 'You need to provide a label.'),
                ],
                'length' => [
                    'rule' => ['minLength', 3],
                    'message' => __d('field', 'Label need to be at least 3 characters long'),
                ],
            ]);

        return $validator;
    }