Reputation: 2355
I am using Laravel 5.2 for my project. Now I need a validation rule namely "after_or_equal" which was introduced in 5.4. So my aim is to clone (or get inspired by it) this rule as it does not exist in 5.2 (I want to implement it as described in the doc).
However I searched Laravel's git repository for this rule but could only find its corresponding error message in English.
So where can I find how they wrote the rule for "after_or_equal" ?
Any help appreciated :-)
Edit : After trying to backport the 5.4 rule
After trying to add (ie duplicate) the required methods called in the source rule ($this->...
) I ended up finding simpler to "manually" do the check directly in the controller. So I first check against the "date" rule, and then use Carbon
to check if the endDate comes after or equal the startDate :
$endDateIsAfterStartDate = $startDateCarbon->diffInDays($endDateCarbon, false) >= 0;
Upvotes: 0
Views: 418
Reputation: 1544
You can get the existing rules for Laravel 5.2 from here Laravel 5.2 Rules
Now in your case when you are unable to find rule can write custom rules by following steps given here Laravel Custom Rules Steps
You can check below links for more information.
Upvotes: 1