0

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;

HelloWorld
  • 2,275
  • 18
  • 29
  • 1
    I find navigating the Laravel source on Github confusing also - [the framework](https://github.com/laravel/framework) is a separate repo to Laravel itself. [This looks like the code you're after](https://github.com/laravel/framework/blob/0b12ef19623c40e22eff91a4b48cb13b3b415b25/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L134) (v5.5). – Don't Panic Mar 29 '20 at 01:11
  • Thanks @Don'tPanic that's exactly what I am after. I saw the comments in illuminate "see Laravel/Framework" but could not find it. Now I know :-) . If you post it as an answer I will accept it. – HelloWorld Mar 29 '20 at 04:39

1 Answers1

1

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.

Brn.Rajoriya
  • 1,534
  • 2
  • 23
  • 35
  • Thanks for your answer. Yet I need the SOURCE code of the rules not the doc :D. Anyway although your answer does not answer my question you provided links that I did not come across and that can be useful. – HelloWorld Mar 29 '20 at 04:36