Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
5cbebb99
Commit
5cbebb99
authored
Mar 22, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #436 from daylerees/date-filters
Date before and after filters
parents
0961f8f7
533112e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
validation.php
application/language/en/validation.php
+2
-0
validator.php
laravel/validator.php
+54
-0
No files found.
application/language/en/validation.php
View file @
5cbebb99
...
...
@@ -59,6 +59,8 @@ return array(
),
"unique"
=>
"The :attribute has already been taken."
,
"url"
=>
"The :attribute format is invalid."
,
"before"
=>
"The :attribute field must contain a date before :date."
,
"after"
=>
"The :attribute field must contain a date after :date."
,
/*
|--------------------------------------------------------------------------
...
...
laravel/validator.php
View file @
5cbebb99
...
...
@@ -646,6 +646,32 @@ class Validator {
return
false
;
}
/**
* Validate the date is before a given date.
*
* @param string $attribute
* @param mixed $value
* @param array $parameters
* @return bool
*/
protected
function
validate_before
(
$attribute
,
$value
,
$parameters
)
{
return
(
strtotime
(
$value
)
<
strtotime
(
$parameters
[
0
]));
}
/**
* Validate the date is after a given date.
*
* @param string $attribute
* @param mixed $value
* @param array $parameters
* @return bool
*/
protected
function
validate_after
(
$attribute
,
$value
,
$parameters
)
{
return
(
strtotime
(
$value
)
>
strtotime
(
$parameters
[
0
]));
}
/**
* Get the proper error message for an attribute and rule.
*
...
...
@@ -877,6 +903,34 @@ class Validator {
return
str_replace
(
':other'
,
$parameters
[
0
],
$message
);
}
/**
* Replace all place-holders for the before rule.
*
* @param string $message
* @param string $attribute
* @param string $rule
* @param array $parameters
* @return string
*/
protected
function
replace_before
(
$message
,
$attribute
,
$rule
,
$parameters
)
{
return
str_replace
(
':date'
,
$parameters
[
0
],
$message
);
}
/**
* Replace all place-holders for the after rule.
*
* @param string $message
* @param string $attribute
* @param string $rule
* @param array $parameters
* @return string
*/
protected
function
replace_after
(
$message
,
$attribute
,
$rule
,
$parameters
)
{
return
str_replace
(
':date'
,
$parameters
[
0
],
$message
);
}
/**
* Get the displayable name for a given attribute.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment