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

Support bean validation annotations @FutureOrPresent and @PastOrPresent #1538

Closed
jreznot opened this issue Nov 14, 2018 · 2 comments
Closed
Assignees
Labels
state: fixed Fixed by the developer type: enhancement New feature or request ver: 7.2.0 Fixed in version
Milestone

Comments

@jreznot
Copy link
Contributor

jreznot commented Nov 14, 2018

Environment

  • Platform version: 7.0
  • Client type: Web

Description of the bug or enhancement

Implement support for PastOrPresent and FutureOrPresent annotations in DatePicker and DateField

@MikhailSilk
Copy link

After adding @FutureOrPresent annotation to the attribute with Date type and select the present date, shows alert messages "must be in the future or in the present"

pribavkindenis added a commit that referenced this issue Jun 24, 2019
@pribavkindenis
Copy link
Contributor

It's O.K. in many cases.

The annotation JavaDoc says: the notion of present here is defined relatively to the type on which the constraint is used. For instance, if the constraint is on a java.time.Year, present would mean the whole current year.

For instance, if you use DatePicker UI component with the Entity attribute below then if you select the present date, com.haulmont.cuba.web.gui.components.WebDatePicker#convertToModel method sets the time of the present date to LocalTime.MIDNIGHT (which is 00:00). That means when you try to validate the component and current time is greater than 00:00, the validation process will fail.

@FutureOrPresent
@Temporal(TemporalType.DATE)
protected java.util.Date someDate;

To solve this problem you could use java.time.LocalDate type instead of java.util.Date or DateField UI component instead of DatePicker.

@MikhailSilk MikhailSilk added the state: fixed Fixed by the developer label Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: fixed Fixed by the developer type: enhancement New feature or request ver: 7.2.0 Fixed in version
Projects
None yet
Development

No branches or pull requests

6 participants