Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validate range of dates with Regula

Tags:

regula

Is there any way to use @Range to validate a range of dates in Regula? (ditto @Min and @Max)

Or do I need to use @Custom?

@Range(min=

and

@Range(max=

do not seem to accept anything of the type Date - only numbers or strings.

like image 644
sq33G Avatar asked Dec 18 '25 20:12

sq33G


1 Answers

Unfortunately @Range only accepts numbers. I think you can do something like this though:

<input type="hidden" 
       name="date" 
       id="date" 
       data-constraints="
           @Future(date='2000/1/1', format='YMD') 
           @Past(date='2010/1/1', format='YMD')" 
/>

This ensures that the date is after 2000/1/1 and before 2010/1/1 (i.e., in between). I didn't document the date parameter because I don't think I had implemented it when I wrote the documentation. Sorry; the documentation is a bit behind because I'm working on rolling version 1.3 of Regula out, that will have a lot more goodies. I'll be getting started on updating the documentation soon!

like image 130
Vivin Paliath Avatar answered Dec 21 '25 09:12

Vivin Paliath