Defines validate rules.

@param mixed ...$validate

@return self
12681
public function validate(...$validate)
    {
        if( $this->validate === [] )
        {
            $this->validate = $validate;
        }
        else
        {
            $this->validate = array_merge($this->validate, $validate);
        }

        return $this;
    }
885339
final public static function setConfig(array $newConfig, $validate = true)
    {
        self::deprecated(__METHOD__);

        if ($validate) {
            self::validateConfig($newConfig);
        }
        self::$config = array_merge(self::$config, $newConfig);
    }
635228
public function merge(Validation $validation) {
        $this->getValidation()->merge($validation, $this->getName());
        return $this;
    }
117272
private function insert($validate = true)
	{
		$this->verifyNotReadonly('insert');

		// Check if validation or beforeCreate returns false.
		if (($validate && !$this->_validate() || !$this->invokeCallback('beforeCreate',false))) {
			return false;
		}

		$table = static::table();

		// Get dirty attributes, or when nothing is dirty we just take all atrributes
		if (!($attributes = $this->dirtyAttributes())) { 
			$attributes = $this->_attributes;
		}

		$pk = $this->getPrimaryKey(true);
		$useSequence = false;

		if ($table->sequence && !isset($attributes[$pk]))
		{
			if (($conn = static::connection()) instanceof OciAdapter) {

				// terrible oracle makes us select the nextval first
				$attributes[$pk] = $conn->getNextSequenceValue($table->sequence);
				$table->insert($attributes);
				$this->_attributes[$pk] = $attributes[$pk];
				
			} else {
				// unset pk that was set to null
				if (array_key_exists($pk, $attributes)) {
					unset($attributes[$pk]);
				}

				$table->insert($attributes, $pk, $table->sequence);
				$useSequence = true;
			}
		} else {

			// Simple insert
			$table->insert($attributes);

		}
			

		// if we've got an autoincrementing/sequenced pk set it
		// don't need this check until the day comes that we decide to support composite pks
		// if (count($pk) == 1)
		{
			$column = $table->getColumnByInflectedName($pk);

			if ($column->autoIncrement || $useSequence) {
				$this->_attributes[$pk] = static::connection()->insertId($table->sequence);
			}
		}

		$this->_newRecord = false;
		$this->invokeCallback('afterCreate', false);
		return true;
	}
1348804
public function validate(array $formData)
    {
        $this->validation = $this->validator->make($formData, $this->getValidationRules());

        if($this->validation->fails())
            throw new FormValidatorException('Validation failed', $this->getValidationErrors());
        return true;
    }
84522
public function validate($formData)
	{
		$formData = $this->normalizeFormData($formData);

		$this->validation = $this->validator->make(
			$formData,
			$this->getValidationRules(),
			$this->getValidationMessages()
		);

		if ($this->validation->fails())
		{
			throw new FormValidationException('Validation failed', $this->getValidationErrors());
		}

		return true;
	}
821922
public function validatesUploadedFile($validate = null)
    {
        if (func_num_args() === 0)
        {
            return $this->validatesUploadedFile;
        }

        return $this->validatesUploadedFile = (bool)$validate;
    }
954009
public function setValidator(Validator $validator) {
        $this->_validator = $validator;

        // Only set model events if we plan on validating
        $this->on('model', $this);

        return $this;
    }
1075733
public function item($item = NULL, $validate = array() ){
    // проверим данные на существование
    if( $item === NULL )                { return NULL; }
    if( !is_array($validate) )          { return NULL; }
    if( !isset($validate['type']) )     { return NULL; }
    if( !is_string($validate['type']) ) { return NULL; }
    if(!isset($this->reformMethods[ $validate['type'] ])){ return NULL; }
    //
    $ValidateClassName = $this->reformMethods[ $validate['type'] ];
    $useClass = new $ValidateClassName();
    // проверим реализует ли класс наш интерфейс
    if ( !($useClass instanceof \Oploshka\Reform\ReformItemInterface ) ) { return NULL; }
  
    $_validate = $validate['validate'] ?? [];
    return $useClass::validate($item, $_validate, $this);
  }
1281121
public function save($validate = true)
    {
        if ($validate) {
            if (!$this->validate()) {
                return false;
            }
        }
        if (!$this->beforeSave()) {
            return false;
        }
        if ($this->_isNewRecord) {
            $r = $this->_db->table($this->_tableName)->insert($this->_updatedAttributes);
            if (is_string($this->_pk)) {
                $this->{$this->_pk} = $r;
                $this->_originalPk = $this->{$this->_pk};
            } else {
                foreach ($this->_pk as $k) {
                    $this->_originalPk[$k] = $this->$k;
                }
            }

            $this->_isNewRecord = false; // so that the next save won't do another insert
            $this->reload();  // to get extra default values.
            $this->afterSave();
            if (is_string($this->_pk) && !$this->{$this->_pk}) {
                return false; // there was an error when saving
            } elseif (!is_string($this->_pk) && !$r) {
                return false;
            }
        }

        if (!$this->_updatedAttributes) {
            $this->afterSave();
            return true; // nothing to save.
        }

        if (is_array($this->_pk)) {
            $c = $p = [];
            foreach ($this->_originalPk as $k => $v) {
                $c[] = "`$k` = :pk_$k";
                $p[":pk_$k"] = $v;
            }
            $r = (bool)$this->_db->table($this->_tableName)
                ->where(implode(" AND ", $c), $p)
                ->update($this->_updatedAttributes);
        } else {
            $r = (bool)$this->_db->table($this->_tableName)
                ->where("`{$this->_pk}` = :__pk")->setParam(':__pk', $this->_originalPk)
                ->update($this->_updatedAttributes);
        }
        if ($r) { // in case it saved the data then make it look like new.
            $this->_updatedAttributes = [];
            if (is_array($this->_pk)) {
                foreach ($this->_pk as $k) {
                    $this->_originalPk[$k] = $this->$k;
                }
            } else {
                $this->_originalPk = $this->{$this->_pk};
            }
        }

        $this->afterSave();

        return $r ?: true;
    }
170271
public function validate($validator)
    {
        // get the previous values (could contain comma-delimited list)

        $previous = $value = $this->Value();

        if (is_string($value) && strstr($value, ",")) {
            $value = explode(",", $value);
        }

        // set the value as an array for parent validation

        $this->setValue($value);

        $validated = parent::validate($validator);

        // restore previous value after validation

        $this->setValue($previous);

        return $validated;
    }
694960
public function validate(&$params)
    {
        if (!is_array($params)) {
            throw new InvalidArgumentException('Please use array params when call validate.');
        }
        $rules = $this->validators;

        if (count($params) < count($rules)) {
            if (!isset($this->defaultValues) || empty($this->defaultValues)) {
                throw new InvalidArgumentException('The params are less than validators.');
            }
            $defaultValues = $this->defaultValues;

            foreach ($defaultValues as $key => $value) {
                if (!isset($params[$key])) {
                    $params[$key] = $value;
                }

            }
        } elseif (count($params) > count($rules)) {
            throw new InvalidArgumentException('The params are more than validators.');
        }
        foreach ($rules as $key => $rule) {
            if (isset($params[$key])) {
                if (is_array($rule)) {
                    $isError = true;

                    foreach ($rule as $subRule) {
                        if (call_user_func([$subRule, 'validate'], $params[$key]) === true) {
                            $isError = false;
                            break;
                        }
                    }
                    if ($isError) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                } else {
                    if (call_user_func([$rule, 'validate'], $params[$key]) === false) {
                        throw new RuntimeException('Wrong type of ' . $this->method . ' method argument ' . $key . '.');
                    }
                }
            } else {
                throw new RuntimeException($this->method . ' method argument ' . $key . ' doesn\'t have default value.');
            }
        }
        return true;
    }
1271088
public function validate()
    {
        foreach ($this as $element) {

            if (
                $element instanceof ValidationAwareInterface ||
                $element instanceof ContainerInterface
            ) {
                $element->validate();
            }
        }
        return $this;
    }
494789
public function validate($command)
	{
		if ($command instanceof SelfValidating) {
            return $this->container->call([$command, 'validate']);
		}
		
		$validatorClass = $this->getValidatorClass($command);
		if(!$validatorClass) {
			return;
		}
        
		$validator = $this->container->make($validatorClass);
		$method = $this->getValidatorMethod($command);

		call_user_func([$validator, $method], $command);
	}
23482
public function set_rules(array $rule_set = [])
    {
        foreach ($rule_set as $attribute_key => $rules) {
            $this->validation->addAttribute($attribute_key, $rules);
        }

        return $this;
    }
1168522
public function storeValues($validate = true)
    {
        $this->populateFormOnce();
        $container = $this->getController()->getSessionContainer();
        $id        = $this->form->getId();

        $container->storeValues($id, (array)$this->form->getValue());
        if ($validate) {
            $container->storeValidationStatus($id, $this->form->validate());
        }
        return $container->getValidationStatus($id);
    }
144907
public function addRule(AbstractRule $validationRule)
    {
        $validationRule->setErrorMessagePrototype($this->errorMessagePrototype);
        $this->rules->attach($validationRule);

        return $this;
    }