|
that's true, it would make a lot of useless groups and it would be better to have the timezone in the ConstraintValidatorContext or something like that.
Yes we should ask it to the user since each user has different needs. Passing the timezone could be optional and fallback to the default timezone like it is oftenly done in other timezone based API's
I'm thinking of something like this:
javax.validation.Validator#validate(object,additionalContext,groups...)
I think the interface of Validator should be enhanced in a retrocompatible way to support passing of additional contextual data that is generic enough to be supported by default specification validators and would be a pain to handle with validation groups. And the Past/Future + Timezone seems to be a good candidate
Setting the timezone on the Validator level (instead of validation interface) would lead to the creation of a validator for each timezone.
I don't know what the additionalContext could look like, perhaps it could have attributes for the specification-supported context customization (like private String timezone), and also a "free" way to pass contextual data to validators for custom user needs (Map<String,Object> ?)
|