before validate attributes
544152
protected function beforeValidate() 
	{
		if(parent::beforeValidate()) {
			if($this->isNewRecord) {
				if($this->actived == 1)
					$this->orders = count(self::getPlugin(1, null, 'data')) + 1;
				else
					$this->orders = 0;
				
				$this->creation_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			} else
				$this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
		}
		return true;
	}
243927
function(options) {
      return {

        /**
         * Check whether an attribute or a set of attributes are valid. It will default to use the model's current values but
         * you can pass in different values to use in the validation process instead.
         * @param attr {String or Object or Array} Either the name of the attribute, an array containing many attribute names, or
         * on object with attribute name to values
         * @param [value] {Any} a value to use for the attribute value instead of using the model's value.
         * @return undefined if no errors, a validation exception if a single attribute, or an object with attribute name as key
         * and the error as the value
         * @method preValidate
         */
        preValidate: function(attr, value) {
          var self = this,
              result = {},
              error;
          if (_.isArray(attr)) {
            _.each(attr, function(attr) {
              error = self.preValidate(attr);
              if (error) {
                result[attr] = error;
              }
            });
            return _.isEmpty(result) ? undefined : result;
          } else if (_.isObject(attr)) {
            _.each(attr, function(value, key) {
              error = self.preValidate(key, value);
              if (error) {
                result[key] = error;
              }
            });
            return _.isEmpty(result) ? undefined : result;
          } else {
            if (_.isUndefined(value) && isNestedModel(this)) {
              value = this.get(attr);
            }
            return validateAttr(this, value, attr);
          }
        },

        // Check to see if an attribute, an array of attributes or the
        // entire model is valid. Passing true will force a validation
        // of the model.
        isValid: function(option) {
          var flattened, attrs, error, invalidAttrs;

          option = option || getOptionsAttrs(options);

          if(_.isString(option)){
            attrs = [option];
          } else if(_.isArray(option)) {
            attrs = option;
          }
          if (attrs) {
            // Loop through all attributes
            _.each(attrs, function (attr) {
              var value;
              if (isNestedModel(this)) {
                value = this.get(attr);
              } else {
                value = flatten(this.attributes)[attr];
              }
              error = validateAttr(this, value, attr);
              if (error) {
                invalidAttrs = invalidAttrs || {};
                invalidAttrs[attr] = error;
              }
            }, this);
          }

          if (option === true) {
            invalidAttrs = this.validate();
          }
          if (invalidAttrs) {
            this.trigger('invalid', this, invalidAttrs, {validationError: invalidAttrs});
          }
          return attrs ? !invalidAttrs : this.validation ? this._isValid : true;
        },

        // This is called by Backbone when it needs to perform validation.
        // You can call it manually without any parameters to validate the
        // entire model.
        validate: function(attrs, setOptions){
          var model = this;
          var opt = _.extend({}, options, setOptions);
          var validatedAttrs = getValidatedAttrs(model, getOptionsAttrs(options));
          var allAttrs = _.extend({}, validatedAttrs, model.attributes, attrs);
          var flattened = _.extend(flatten(allAttrs), attrs); // allow people to pass in nested attributes
          var changedAttrs = attrs ? flatten(attrs) : flattened;
          var result = validateModel(model, allAttrs, _.pick(flattened, _.keys(validatedAttrs)));
          model._isValid = result.isValid;

          // Trigger validated events.
          // Need to defer this so the model is actually updated before
          // the event is triggered.
          _.defer(function() {
            model.trigger('validated', model._isValid, model, result.invalidAttrs);
            model.trigger('validated:' + (model._isValid ? 'valid' : 'invalid'), model, result.invalidAttrs);
          });

          // Return any error messages to Backbone, unless the forceUpdate flag is set.
          // Then we do not return anything and fools Backbone to believe the validation was
          // a success. That way Backbone will update the model regardless.
          if (!opt.forceUpdate && _.intersection(_.keys(result.invalidAttrs), _.keys(changedAttrs)).length > 0) {
            return result.invalidAttrs;
          }
        }
      };
    }
318195
private void onValidity(String paramString, boolean checkValidity, SingularAttribute<? super X, ?> attribute)
    {
        if (checkValidity)
        {
            checkForValid(paramString, attribute);

        }
    }
608132
protected function beforeValidate() 
	{
		$controller = strtolower(Yii::app()->controller->id);
		$action = strtolower(Yii::app()->controller->action->id);
		$currentAction = strtolower(Yii::app()->controller->id.'/'.Yii::app()->controller->action->id);

		if(parent::beforeValidate()) {
			if($currentAction == 'settings/general') {
				if($this->online != 1) {
					if($this->construction_date == '')
						$this->addError('construction_date', Yii::t('phrase', 'Maintenance date cannot be blank.'));
					if($this->online == 0 && $this->construction_text['maintenance'] == '')
						$this->addError('construction_text[maintenance]', Yii::t('phrase', 'Maintenance text cannot be blank.'));
					if($this->online == 2 && $this->construction_text['comingsoon'] == '')
						$this->addError('construction_text[comingsoon]', Yii::t('phrase', 'Coming Soon text cannot be blank.'));
				}

				if($this->event_i == 0) {
					$this->event_startdate = '00-00-0000';
					$this->event_finishdate = '00-00-0000';
					
				} else {
					$condition = 0;
					if($this->event_startdate != '' && in_array(date('Y-m-d', strtotime($this->event_startdate)), array('0000-00-00','1970-01-01','0002-12-02','-0001-11-30'))) {
						$condition = 0;
						$this->addError('event_startdate', Yii::t('phrase', 'Event Startdate cannot be blank or default date.'));
					} else
						$condition = 1;
					if($this->event_finishdate != '' && in_array(date('Y-m-d', strtotime($this->event_finishdate)), array('0000-00-00','1970-01-01','0002-12-02','-0001-11-30'))) {
						$condition = 0;
						$this->addError('event_finishdate', Yii::t('phrase', 'Event Finishdate cannot be blank or default date.'));
					} else
						$condition = 1;
					if($condition == 1 && (date('Y-m-d', strtotime($this->event_startdate)) >= date('Y-m-d', strtotime($this->event_finishdate))))
						$this->addError('event_finishdate', Yii::t('phrase', 'Event Finishdate tidak boleh lebih kecil'));
				}
			}
			
			$this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
		}
		return true;
	}
107337
public function beforeSave()
    {
        /* @var $model ActiveRecord */
        $model = $this->owner;
        foreach ($this->attributes as $attr => $options) {
            $this->ensureAttributes($attr, $options);
            if ($file = UploadedFile::getInstance($model, $attr)) {
                $this->createDirIfNotExists($attr);
                if (!$model->isNewRecord) {
                    $this->deleteFiles($attr);
                }
                $fileName = uniqid() . '.' . $file->extension;
                $model->{$attr} = $fileName;
                $file->saveAs($this->getSavePath($attr) . $fileName);
            } elseif (isset($model->oldAttributes[$attr])) {
                $model->{$attr} = $model->oldAttributes[$attr];
            }
        }
    }
505852
protected function validateBefore($attribute, $value, $parameters)
	{
		if ( ! ($date = strtotime($parameters[0])))
		{
			return strtotime($value) < strtotime($this->getValue($parameters[0]));
		}
		else
		{
			return strtotime($value) < $date;
		}
	}
819673
def validate(self, data):
        '''
        
        '''
        for prop in self.properties:
            if prop.id in data:
                if prop.type == 'string':
                    if not isinstance(data[prop.id], basestring):
                        raise PresetFieldTypeException("property '{}' must be of type string".format(prop.id))
                elif prop.type == 'enum':
                    if not isinstance(data[prop.id], basestring):
                        raise PresetFieldTypeException("property '{}' must be of type string".format(prop.id))
                    if data[prop.id] not in prop.values:
                        raise PresetException("property '{}' can be one of {}".format(prop.id, prop.values))
            else:
                if prop.required:
                    raise PresetMissingFieldException("missing required property: '{}'".format(prop.id))
936942
function() {
    // Check for unknown attributes
    var key, unknownAttrs = []
    for (key in obj) {
      if (!self.validators.hasOwnProperty(key))
        unknownAttrs.push(key)
    }
    if (unknownAttrs.length)
      self._merge(validationErrors, 'unknown attributes [' + unknownAttrs.join(', ') + ']', prefix)
      //validationErrors[prefix || '.'] = 'unknown attributes [' + unknownAttrs.join(', ') + ']'

    // Run the `after` hook only if there is no validation error.
    if (isValid && self.after) {
      try {
        self.after.call(obj)
      } catch (err) {
        if(!_handleError(err)) return done(err)
      }
    }
    done(null, validationErrors)
  }
259279
def validate!(filter, names)
      unless filters.empty?
        raise InvalidFilterError, 'multiple filters in array block'
      end

      unless names.empty?
        raise InvalidFilterError, 'attribute names in array block'
      end

      if filter.default?
        raise InvalidDefaultError, 'default values in array block'
      end

      nil
    end
1193134
public function validate() : void
    {
        if (null === $this->is_valid) {
            if (null === $this->user_value && null !== $this->default_value) {
                // There is a preset value, and its not being changed
                $this->is_valid = true;
            } elseif (true == $this->user_value || 1 == $this->user_value) {
                $this->user_value = 1;
                $this->is_valid = true;
            } elseif (false == $this->user_value || 0 == $this->user_value || '' == $this->user_value) {
                $this->user_value = 0;
                $this->is_valid = true;
            } elseif (false == $this->validator) {
                // This field does not get validated
                $this->is_valid = true;
            } else {
                $this->is_valid = false;
                $this->error = 'The provided value is not valid. Please enter a valid value.';
            }
        }

        // Check if the input is different from the default value
        if ($this->is_valid && null !== $this->user_value) {
            $this->is_changed = ($this->default_value != $this->user_value);
        }
    }
792651
protected function beforeValidate() {
		if(parent::beforeValidate()) {		
			if($this->isNewRecord) {
				$this->user_id = Yii::app()->user->id;
			}
		}
		return true;
	}
928951
function(attr, options) {
      if (!(attr in this.attributes)) return this;
      options || (options = {});
      var value = this.attributes[attr];

      // Run validation.
      var validObj = {};
      validObj[attr] = void 0;
      if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;

      // Remove the attribute.
      delete this.attributes[attr];
      delete this._escapedAttributes[attr];
      if (attr == this.idAttribute) delete this.id;
      this._changed = true;
      if (!options.silent) {
        this.trigger('change:' + attr, this, void 0, options);
        this.change(options);
      }
      return this;
    }
562535
protected function before_validate() {
        $this->beforeupdate = null;

        // During update.
        if ($this->get('id')) {
            $this->beforeupdate = new self($this->get('id'));
        }
    }
222911
private static function validateAttributes($model, $name, &$attributes)
    {
        // Should be an array.
        if (!is_array($attributes)) {
            $attributes = [$attributes];
        }

        // Is empty, use the name of the table + name.
        if (empty($attributes)) {
            $attributes = [sprintf('%s.%s', $model->getTable(), $name)];
        }

        // Check each of the attribute values.
        // Convert any prepended with a curly to an expression.
        foreach ($attributes as &$value) {
            if (substr($value, 0, 1) === '#' || substr($value, 0, 1) === '{') {
                $value = new Expression(substr($value, 1));
            }
        }
    }
964236
function(model, attrs, validatedAttrs) {
      var error,
          invalidAttrs = {},
          isValid = true,
          computed = _.clone(attrs);

      _.each(validatedAttrs, function(val, attr) {
        error = validateAttrWithOpenArray(model, attr, val, computed);
        if (error) {
          invalidAttrs[attr] = error;
          isValid = false;
        }
      });

      return {
        invalidAttrs: invalidAttrs,
        isValid: isValid
      };
    }
275782
public function beforeDelete()
    {
        foreach ($this->attributes as $attr => $options) {
            $this->ensureAttributes($attr, $options);
            $this->deleteFiles($attr);
        }
    }
273279
public function beforeValidate()
    {
        if (!parent::beforeValidate()) {
            return false;
        }

        $dsn = '';
        switch ($this->dbType) {
            case 'mysql':
                $dsn = "mysql:host={$this->dbHost};dbname={$this->dbName}";
                break;
        }

        // Test the Db
        $db = Yii::$app->getDb();
        $db->dsn = $dsn;
        $db->username = $this->dbUsername;
        $db->password = $this->dbPassword;
        $db->tablePrefix = $this->dbTablePrefix;
        try {
            $db->open();
        } catch (\Exception $e) {
            $this->globalError = $e->getMessage();
            return false;
        }
        return true;
    }