Fixing merge issues.
This commit is contained in:
0
after:1986-05-28
Normal file
0
after:1986-05-28
Normal file
0
after:1986-28-05,
Normal file
0
after:1986-28-05,
Normal file
@@ -36,6 +36,7 @@ return array(
|
|||||||
"countbetween" => "The :attribute must have between :min and :max selected elements.",
|
"countbetween" => "The :attribute must have between :min and :max selected elements.",
|
||||||
"countmax" => "The :attribute must have less than :max selected elements.",
|
"countmax" => "The :attribute must have less than :max selected elements.",
|
||||||
"countmin" => "The :attribute must have at least :min selected elements.",
|
"countmin" => "The :attribute must have at least :min selected elements.",
|
||||||
|
"date_format" => "The :attribute must have a valid date format.",
|
||||||
"different" => "The :attribute and :other must be different.",
|
"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.",
|
||||||
|
|||||||
0
before:1986-05-28
Normal file
0
before:1986-05-28
Normal file
0
before:1986-28-05,
Normal file
0
before:1986-28-05,
Normal file
@@ -205,6 +205,14 @@ Many times, when updating a record, you want to use the unique rule, but exclude
|
|||||||
|
|
||||||
> **Note:** The **before** and **after** validation rules use the **strtotime** PHP function to convert your date to something the rule can understand.
|
> **Note:** The **before** and **after** validation rules use the **strtotime** PHP function to convert your date to something the rule can understand.
|
||||||
|
|
||||||
|
#### Validate that a date attribute conforms to a given format:
|
||||||
|
|
||||||
|
'start_date' => 'date_format:H\\:i'),
|
||||||
|
|
||||||
|
> **Note:** The backslash escapes the colon so that it does not count as a parameter separator.
|
||||||
|
|
||||||
|
The formatting options for the date format are described in the [PHP documentation](http://php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters).
|
||||||
|
|
||||||
<a name="rule-email"></a>
|
<a name="rule-email"></a>
|
||||||
### E-Mail Addresses
|
### E-Mail Addresses
|
||||||
|
|
||||||
|
|||||||
@@ -483,6 +483,28 @@ class ValidatorTest extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertFalse(Validator::make($input, $rules)->valid());
|
$this->assertFalse(Validator::make($input, $rules)->valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the date_format validation rule.
|
||||||
|
*
|
||||||
|
* @group laravel
|
||||||
|
*/
|
||||||
|
public function testTheDateFormatRule()
|
||||||
|
{
|
||||||
|
$input = array('date' => '15-Feb-2009');
|
||||||
|
$rules = array('date' => 'date_format:j-M-Y');
|
||||||
|
$this->assertTrue(Validator::make($input, $rules)->valid());
|
||||||
|
|
||||||
|
$input['date'] = '2009-02-15,15:16:17';
|
||||||
|
$rules['date'] = 'date_format:"Y-m-d,H:i:s"';
|
||||||
|
$this->assertTrue(Validator::make($input, $rules)->valid());
|
||||||
|
|
||||||
|
$input['date'] = '2009-02-15';
|
||||||
|
$this->assertFalse(Validator::make($input, $rules)->valid());
|
||||||
|
|
||||||
|
$input['date'] = '15:16:17';
|
||||||
|
$this->assertFalse(Validator::make($input, $rules)->valid());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the validator sets the correct messages.
|
* Test that the validator sets the correct messages.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -759,6 +759,19 @@ class Validator {
|
|||||||
return (strtotime($value) > strtotime($parameters[0]));
|
return (strtotime($value) > strtotime($parameters[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the date conforms to a given format.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @param array $parameters
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function validate_date_format($attribute, $value, $parameters)
|
||||||
|
{
|
||||||
|
return date_create_from_format($parameters[0], $value) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the proper error message for an attribute and rule.
|
* Get the proper error message for an attribute and rule.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user