added same and different validation rules.
This commit is contained in:
parent
d462a72981
commit
554d390f1e
|
@ -29,6 +29,7 @@
|
||||||
"string" => "The :attribute must be between :min - :max characters.",
|
"string" => "The :attribute must be between :min - :max characters.",
|
||||||
),
|
),
|
||||||
"confirmed" => "The :attribute confirmation does not match.",
|
"confirmed" => "The :attribute confirmation does not match.",
|
||||||
|
"different" => "The :attribute and :other must be different.",
|
||||||
"email" => "The :attribute format is invalid.",
|
"email" => "The :attribute format is invalid.",
|
||||||
"exists" => "The selected :attribute is invalid.",
|
"exists" => "The selected :attribute is invalid.",
|
||||||
"image" => "The :attribute must be an image.",
|
"image" => "The :attribute must be an image.",
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
"not_in" => "The selected :attribute is invalid.",
|
"not_in" => "The selected :attribute is invalid.",
|
||||||
"numeric" => "The :attribute must be a number.",
|
"numeric" => "The :attribute must be a number.",
|
||||||
"required" => "The :attribute field is required.",
|
"required" => "The :attribute field is required.",
|
||||||
|
"same" => "The :attribute and :other must match.",
|
||||||
"size" => array(
|
"size" => array(
|
||||||
"numeric" => "The :attribute must be :size.",
|
"numeric" => "The :attribute must be :size.",
|
||||||
"file" => "The :attribute must be :size kilobyte.",
|
"file" => "The :attribute must be :size kilobyte.",
|
||||||
|
|
|
@ -253,9 +253,7 @@ protected function validate_required($attribute, $value)
|
||||||
*/
|
*/
|
||||||
protected function validate_confirmed($attribute, $value)
|
protected function validate_confirmed($attribute, $value)
|
||||||
{
|
{
|
||||||
$confirmed = $attribute.'_confirmation';
|
return $this->validate_same($attribute, $value, array($attribute.'_confirmation'));
|
||||||
|
|
||||||
return isset($this->attributes[$confirmed]) and $value == $this->attributes[$confirmed];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,6 +270,36 @@ protected function validate_accepted($attribute, $value)
|
||||||
return $this->validate_required($attribute, $value) and ($value == 'yes' or $value == '1');
|
return $this->validate_required($attribute, $value) and ($value == 'yes' or $value == '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate that an attribute is the same as another attribute.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @param array $parameters
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validate_same($attribute, $value, $parameters)
|
||||||
|
{
|
||||||
|
$other = $parameters[0];
|
||||||
|
|
||||||
|
return isset($this->attributes[$other]) and $value == $this->attributes[$other];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate that an attribute is different from another attribute.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @param array $parameters
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validate_different($attribute, $value, $parameters)
|
||||||
|
{
|
||||||
|
$other = $parameters[0];
|
||||||
|
|
||||||
|
return isset($this->attributes[$other]) and $value != $this->attributes[$other];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that an attribute is numeric.
|
* Validate that an attribute is numeric.
|
||||||
*
|
*
|
||||||
|
@ -727,7 +755,9 @@ protected function attribute($attribute)
|
||||||
// If no language line has been specified for the attribute, all of
|
// If no language line has been specified for the attribute, all of
|
||||||
// the underscores will be removed from the attribute name and that
|
// the underscores will be removed from the attribute name and that
|
||||||
// will be used as the attribtue name in the message.
|
// will be used as the attribtue name in the message.
|
||||||
$display = Lang::line("{$bundle}validation.attributes.{$attribute}")->get($this->language);
|
$line = "{$bundle}validation.attributes.{$attribute}";
|
||||||
|
|
||||||
|
$display = Lang::line($line)->get($this->language);
|
||||||
|
|
||||||
return (is_null($display)) ? str_replace('_', ' ', $attribute) : $display;
|
return (is_null($display)) ? str_replace('_', ' ', $attribute) : $display;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue