Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added ability to reference fields in before and after validators#1824

Merged
taylorotwell merged 2 commits into
laravel:masterfrom
shachibista:master
Jul 9, 2013
Merged

Added ability to reference fields in before and after validators#1824
taylorotwell merged 2 commits into
laravel:masterfrom
shachibista:master

Conversation

@shachibista
Copy link
Copy Markdown
Contributor

Allows before and after validators to refer to other fields such as:

array(
    'start_date' => 'after:2013-07-06',
    'end_date' => 'after:start_date'
)

@robclancy
Copy link
Copy Markdown
Contributor

Yeah this would be good. I use my own custom little wrappers to do this but I can see it of being of use a fair bit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just:

$other = isset( $this->data[$parameters[0]] ) ? $this->getValue( [$parameters[0] ) : $parameters[0];
return strtotime($value) < strtotime($other);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An explicit if-else is more readable and conveys the purpose in a clearer manner.

taylorotwell added a commit that referenced this pull request Jul 9, 2013
Added ability to reference fields in before and after validators
@taylorotwell taylorotwell merged commit 6118315 into laravel:master Jul 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants