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

Start_in date field cannot be nil #23

Open
ohenrik opened this issue Jun 25, 2015 · 7 comments
Open

Start_in date field cannot be nil #23

ohenrik opened this issue Jun 25, 2015 · 7 comments

Comments

@ohenrik
Copy link

ohenrik commented Jun 25, 2015

It seems like the field containing the from date (start date) has to be present or the validation for overlapping dates will be fired. I assume this is a bug as not all records necessarily need to have a date period specified.

I'm using ruby version 2.2.1 and Rails 4.2.1

@robinbortlik
Copy link
Owner

Hi @ohenrik
can you please paste a validation code from you model and some example of records, so I can simulate this situation?

@ohenrik
Copy link
Author

ohenrik commented Jun 25, 2015

Hi

This is my validation method validates :start_date, :end_date, overlap: true

The records are simply just to have both the start and the end date empty. I think we have found the problem and I'm working on a fork. So if you want i can make a pull request a bit later?

@robinbortlik
Copy link
Owner

@ohenrik it would be awesome. So I will wait.

@robinbortlik
Copy link
Owner

Hi @ohenrik , did you do any progress with this issue? I'm afraid that what you found is not a bug, but a feature ;)
I mean, if one record has end_at nil then it behaves like endless event. That's mean that there can't be any other record starting or ending after.

@robinbortlik
Copy link
Owner

And if you create record which have start_at => nil and end_at => nil then it behave like record beginning on the beginning of time and ending on the end of time. So there can't be any other record.

@ohenrik
Copy link
Author

ohenrik commented Jun 30, 2015

Hi @robinbortlik, sorry not yet, haven't had time yet.

I agree that that is smart when eather start date or the end date is empty, since then for example an event can go on for ever. However when both of them are empty it should be considered as "no date range set" or else this validation will also validate that these fields are set if any other records exists. (e.g. validates presence of ). which is not always desired.

At least there should be an option to allows both dates to be empty and then not validate them.

@ohenrik
Copy link
Author

ohenrik commented Jun 30, 2015

Also the validation message will often become confusing, since it is not obvious that and empty date means since forever and until forever. I feel that empty start and end dates should be eather allowed or validated with the "presence" validator.

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

No branches or pull requests

2 participants