I'll-Be-Back
I'll-Be-Back

Reputation: 10828

Date validation in Laravel

It appear there is no validation rule in Laravel that start_date and end_date can not be the same.

How do I overcome this?

Upvotes: 0

Views: 469

Answers (1)

codebob
codebob

Reputation: 81

Try this one in controller/model where you defined rules to check, and get the proper validation you want

Validator::extend('before_equal', function($attribute, $value, $parameters) {
    return strtotime(Input::get($parameters[0])) >= strtotime($value);
});

$rules = array(
    'start'=>'required|date|before_equal:stop',
    'stop'=>'required|date',
);

Upvotes: 1

Related Questions