Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Add not_before and not_after rules #16136

Closed

Conversation

mnabialek
Copy link
Contributor

Added to 2 date rules that I always miss:

not_before - same date or after
not_after - same date or before

A bit of code has been refactored, so if approved someone more experienced should probably also look at this to make sure nothing won't be broken

@themsaid
Copy link
Member

themsaid commented Oct 27, 2016

What's the difference between not_before and the current after? Why not do after:2016-12-31

@mnabialek
Copy link
Contributor Author

after accepts only date after date given not including given date and not_before accepts given date and date after it, so not_before is after + given date. Same with not_after rule.

For example, now when I want to set paid_at field that should be today or future I have to use before:tomorrow and it would be much obvious to use not_after:today but it will be even more helpful when I have 2 dates and day might equal or second should be after the first. Using current rules after or before won't work because they won't handle case when dates are same.

@themsaid
Copy link
Member

I think before:tomorrow serves the purpose, it means today or any day in the past is valid which is what you want to have, right?

@mnabialek
Copy link
Contributor Author

mnabialek commented Oct 27, 2016

Yes, this case yes, it can be do this way, but if have 2 date fields: start and end and we want end >= start as far as I know there's now way to validate it using predefined validation rules, after rule will fail when end = start

@themsaid
Copy link
Member

themsaid commented Oct 31, 2016

You can do something like:

"end" => "after:".Carbon::createFromFormat("Y-m-d H:i:s", input('start'))->yesterday()

@mnabialek
Copy link
Contributor Author

Yes, of course this can be done this way. I can calculate any date and type in, but as you see syntax would be much cleaner if such rules could be used. If you look at http://stackoverflow.com/questions/27018045/how-to-make-an-input-date-field-greater-than-or-equal-to-another-date-field-usin you will see that other people also are looking for after and before that use >= or <= operator

@mnabialek mnabialek deleted the 5.3-add_not_before_not_after_rules branch November 5, 2017 17:02
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.

3 participants