src/mako/validator/Validator.php
protected function validateField(string $field, string $rule): bool
	{
		$parsedRule = $this->parseRule($rule);

		$rule = $this->ruleFactory($parsedRule->name, $parsedRule->parameters);

		// Just return true if the input field is empty and the rule doesn't validate empty input

		if($this->isInputFieldEmpty($inputValue = Arr::get($this->input, $field)) && $rule->validateWhenEmpty() === false)
		{
			return true;
		}

		// Validate input

		if($rule->validate($inputValue, $this->input) === false)
		{
			$this->errors[$field] = $this->getErrorMessage($rule, $field, $parsedRule);

			return $this->isValid = false;
		}

		return true;
	}
protected function validateField(string $field, string $rule): bool
	{
		$parsedRule = $this->parseRule($rule);

		$rule = $this->ruleFactory($parsedRule->name, $parsedRule->parameters);

		// Just return true if the input field is empty and the rule doesn't validate empty input

		if($this->isInputFieldEmpty($inputValue = Arr::get($this->input, $field)) && $rule->validateWhenEmpty() === false)
		{
			return true;
		}

		// Validate input

		if($rule->validate($inputValue, $this->input) === false)
		{
			$this->errors[$field] = $this->getErrorMessage($rule, $field, $parsedRule);

			return $this->isValid = false;
		}

		return true;
	}
protected function validateField ( string $ field , string $ rule ) : bool { $ parsedRule = $ this -> parseRule ( $ rule ) ; $ rule = $ this -> ruleFactory ( $ parsedRule -> name , $ parsedRule -> parameters ) ; // Just return true if the input field is empty and the rule doesn't validate empty input if ( $ this -> isInputFieldEmpty ( $ inputValue = Arr :: get ( $ this -> input , $ field ) ) && $ rule -> validateWhenEmpty ( ) === false ) { return true ; } // Validate input if ( $ rule -> validate ( $ inputValue , $ this -> input ) === false ) { $ this -> errors [ $ field ] = $ this -> getErrorMessage ( $ rule , $ field , $ parsedRule ) ; return $ this -> isValid = false ; } return true ; }
Validates the field using the specified rule.

@param  string $field Field name
@param  string $rule  Rule
@return bool
Validates the field using the specified rule .