Perform validation with the specified ruleset.

@param  \Illuminate\Database\Eloquent\Model $model
@param  string $event
@return boolean
495007
protected function performValidation(Model $model, $event)
    {
        // If the model has validating enabled, perform it.
        if ($model->getValidating()) {
            // Fire the namespaced validating event and prevent validation
            // if it returns a value.
            if ($this->fireValidatingEvent($model, $event) !== null) {
                return;
            }

            if ($model->isValid() === false) {
                // Fire the validating failed event.
                $this->fireValidatedEvent($model, 'failed');

                if ($model->getThrowValidationExceptions()) {
                    $model->throwValidationException();
                }

                return false;
            }
            // Fire the validating.passed event.
            $this->fireValidatedEvent($model, 'passed');
        } else {
            $this->fireValidatedEvent($model, 'skipped');
        }
    }
1171883
public static function orm_notify(Model $instance, $event)
	{
		if (method_exists($instance, $method = '_event_'.$event))
		{
			call_user_func(array($instance, $method));
		}
	}
94715
public function validateAttribute($model, $attribute)
    {
        $value = $model->$attribute;
        if (!is_numeric($value) && !is_float($value)) {
            return $model->addError($attribute, Yii::t('luya', $this->message, ['attribute' => $model->getAttributeLabel($attribute)]));
        }
    }
487060
public boolean handleEvent(ValidationEvent event) {
		LOGGER.info("");
		LOGGER.info("EventT");
		LOGGER.info("\tSeverity: " + event.getSeverity());
		LOGGER.info("\tMessage: " + event.getMessage());
		LOGGER.info("\tLinked Excpetion: " + event.getLinkedException());
		LOGGER.info("\tLocator");
		LOGGER.info("\tLine Number: "
				+ event.getLocator().getLineNumber());
		LOGGER.info("\tColumn Number: "
				+ event.getLocator().getColumnNumber());
		LOGGER.info("\tOffset: " + event.getLocator().getOffset());
		LOGGER.info("\tObject: " + event.getLocator().getObject());
		LOGGER.info("\tNode: " + event.getLocator().getNode());
		LOGGER.info("\tURL: " + event.getLocator().getURL());
		return true;
	}
609405
public function check($model)
    {
        $moderated = false;

        foreach ($model->getModerateList() as $id => $moderation) {
            $rules = explode('|', $moderation);

            foreach ($rules as $rule) {
                $action = explode(':', $rule);
                $options = isset($action[1]) ? $action[1] : null;

                $method = $action[0];
                if ($this->$method($model->$id, $options)) {
                    return $moderated = true;
                }
            }

            // No reason to keep going
            if ($moderated === true) {
                return $moderated;
            }
        }

        return $moderated;
    }
481044
public function validateAttribute($model, $attribute)
    {
        if (
            $this->targetClass !== null
            && $model->$attribute instanceof $this->targetClass
            && !empty($model->$attribute->isNewRecord)
        ) {
            return;
        }

        if ($model->isRelationPopulated($attribute)) {
            return;
        }

        parent::validateAttribute($model, $attribute);
    }
1188727
private function validateRecord()
    {
        // Abort if beforeValidate() fails
        if ($this->fireModelEvent('validating') === false) return false;

        $validator = Validator::make($this->getAttributes(), $this->rules, $this->messages);
        $result = $validator->passes();

        // Update errors based on result
        $this->errors = ($result) ? new MessageBag : $validator->messages();

        $this->fireModelEvent('validated', false);

        return $result;
    }
1224071
public function validateAttribute($model, $attribute)
    {
        $countries = [];
        if ($this->country !== null) {
            $countries = [$this->country];
        } elseif ($this->countryAttribute !== null) {
            $countries = [$model->{$this->countryAttribute}];
        } elseif (is_array($this->countries) && count($this->countries) > 0) {
            $countries = $this->countries;
        }

        if (count($countries) <= 0) {
            $countries = self::getPhoneUtil()->getSupportedRegions();
        }

        foreach ($countries as $country) {
            try {
                $number = self::getPhoneUtil()->parse($model->$attribute, $country);

                if (self::getPhoneUtil()->isValidNumberForRegion($number, $country)) {
                    if ($this->format) {
                        $model->$attribute = self::getPhoneUtil()->format($number, PhoneNumberFormat::INTERNATIONAL);
                    }

                    $this->_successValidation = true;
                    break;
                }
            } catch (NumberParseException $e) {
                $this->addError($model, $attribute, $this->numberParseExceptionMessage);
            }
        }

        if (!$this->_successValidation) {
            $this->addError($model, $attribute, $this->notValidPhoneNumberMessage);
        }

        return $this->_successValidation;
    }
1066137
public function validate(\Magento\Framework\Model\AbstractModel $model)
    {
        $isShopgateOrder = (int) in_array($model->getData(self::CLIENT_ATTRIBUTE), self::APP_CLIENTS);
        // TODO add validation for web checkout
        $model->setData(self::IS_SHOPGATE_ORDER, $isShopgateOrder);

        return parent::validate($model);
    }
186469
public function validateForm(FormEvent $event)
    {
        $form = $event->getForm();

        if ($form->isRoot()) {
            // Form groups are validated internally (FormValidator). Here we don't set groups as they are retrieved into the validator.
            foreach ($this->validator->validate($form) as $violation) {
                // Allow the "invalid" constraint to be put onto
                // non-synchronized forms
                // ConstraintViolation::getConstraint() must not expect to provide a constraint as long as Symfony\Component\Validator\ExecutionContext exists (before 3.0)
                $allowNonSynchronized = (null === $violation->getConstraint() || $violation->getConstraint() instanceof Form) && Form::NOT_SYNCHRONIZED_ERROR === $violation->getCode();

                $this->violationMapper->mapViolation($violation, $form, $allowNonSynchronized);
            }
        }
    }
1282496
public static function isValidNextStatus($model, $status_id)
	{
		$eventSequence = $model->getEventSequence($status_id);
		foreach ($eventSequence['before'] as $event) {
			if ($model->hasEventHandlers($event->name)) {
				$model->trigger($event->name, $event);
				if ($event->isValid === false) {
					return false;
				}
			}
		}
		return true;
	}
1066769
public function validate($field, $value, $validator) {
		if(empty($value)) return true;
		return (bool) preg_match($this->regex, $value);
	}
716043
public function beforeValidate(Model $model, $options = array()) {
        if (empty($this->settings[$model->alias])) {
            return true;
        }

        foreach ($this->settings[$model->alias] as $field => $rules) {
            $validations = array();

            foreach ($rules as $rule => $setting) {
                $set = $this->_defaults[$rule];

                // Parse out values
                if (!is_array($setting) || !isset($setting['value'])) {
                    $setting = array('value' => $setting);
                }

                switch ($rule) {
                    case 'required':
                        $arg = (bool) $setting['value'];
                    break;
                    case 'type':
                    case 'mimeType':
                    case 'extension':
                        $arg = (array) $setting['value'];
                    break;
                    default:
                        $arg = (int) $setting['value'];
                    break;
                }

                if (!isset($setting['rule'])) {
                    $setting['rule'] = array($rule, $arg);
                }

                if (isset($setting['error'])) {
                    $setting['message'] = $setting['error'];
                    unset($setting['error']);
                }

                unset($setting['value']);

                // Merge settings
                $set = array_merge($set, $setting);

                // Apply validations
                if (is_array($arg)) {
                    $arg = implode(', ', $arg);
                }

                $set['message'] = __d('uploader', $set['message'], $arg);

                $validations[$rule] = $set;
            }

            if ($validations) {
                if (!empty($model->validate[$field])) {
                    $currentRules = $model->validate[$field];

                    // Fix single rule validate
                    if (isset($currentRules['rule'])) {
                        $currentRules = array(
                            $currentRules['rule'] => $currentRules
                        );
                    }

                    $validations = $currentRules + $validations;
                }

                // Remove notEmpty for uploads
                if (isset($model->data[$model->alias][$field]['tmp_name']) && isset($validations['notEmpty'])) {
                    unset($validations['notEmpty']);
                }

                $this->_validations[$field] = $validations;
                $model->validate[$field] = $validations;
            }
        }

        return true;
    }
594207
public function beforeValidationOnUpdate(Event $event, Model $model)
    {
        if ($model instanceof ICredentialsHolder && $model->getPlainPassword()) {
            $this->createPassword($model);
        }
    }
634671
protected function validateAttributeInternal($model, $attribute)
    {
        $value = $model->{$attribute};

        $result = ($this->type == FormatHelper::TYPE_LIST)
            ? $this->validateListValue($model, $value)
            : $this->validateValue($value);

        if (!empty($result)) {
            $this->addError($model, $attribute, $result[0], $result[1]);

            return;
        }

        Yii::info('Type validation success'
            . PHP_EOL . "Result value for '$attribute': {$this->filteredAttribute}", __METHOD__);
        $model->{$attribute} = $this->filteredAttribute;
    }
495637
public function isBlameable(Model $model, $event = null)
    {
        return $event ?
            array_key_exists($event, $this->getBlameableFields($model)) :
            count($this->getBlameableFields($model)) > 0;
    }
323259
public function afterInitialize(Event $event, ModelsManager $manager, $model)
    {
        //Reflector
        /** @var \Phalcon\Annotations\Reflection $reflector */
        $reflector = $this->annotations->get($model);
        /**
         * Read the annotations in the class' docblock
         */
        $annotations = $reflector->getClassAnnotations();
        if ($annotations) {
            /**
             * Traverse the annotations
             */
            foreach ($annotations as $annotation) {
                switch ($annotation->getName()) {
                    /**
                     * Initializes the model's source
                     */
                    case 'Source':
                        $arguments = $annotation->getArguments();
                        $model->setConnectionService($arguments[0]);
                        $manager->setModelSource($model, $arguments[1]);
                        break;
                    /**
                     * Initializes Has-Many relations
                     */
                    case 'HasMany':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addHasMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                    /**
                     * Initializes Has-Many-To-Many relations
                     */
                    case 'HasManyToMany':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[6])) {
                            $arguments[6] = null;
                        }
                        $manager->addHasManyToMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4], $arguments[5], $arguments[6]);
                        break;
                    /**
                     * Initializes Has-One relations
                     */
                    case 'HasOne':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addHasOne($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                    /**
                     * Initializes Has-Many relations
                     */
                    case 'BelongsTo':
                        $arguments = $annotation->getArguments();
                        if (!isset($arguments[3])) {
                            $arguments[3] = null;
                        }
                        $manager->addBelongsTo($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]);
                        break;
                }
            }
        }
    }