[hibernate-dev] [HV] Design philosophy
Emmanuel Bernard
emmanuel at hibernate.org
Wed Apr 11 12:38:41 EDT 2012
On 11 avr. 2012, at 17:12, Hardy Ferentschik wrote:
>>
>> To me, it adds complexity :
>>
>> - in HV's code but that's not a strong factor in this case
>> - more doc
>> - as a user looking at @Email when I use it, I have to understand why such an option has been added and if I need it
>>
>> And I don't see why you don't add regexp to CreditCardNumber, ModCheck, NotBlank, NotEmpty and SafeHtml. There are "equally valid" use cases for that. But if you add them to all these annotations, I will start to question your massive duplication error.
>
> I think that's a bit exaggerated, but to be fair you have a point. I personally draw my line in the sand where things stand right now and I am not having any plans to add a regular expression
> to any of the above constraints.
I was not facetious:
- CreditCardNumer: use a regexp to reduce valid credit cards to specific countries or specific bank entities
- ModCheck: assuming data is stored like credit card numbers (such as bank entity), use this data to filter out numbers
- SafeHtml: filter out some offensive words
- NotBlank / NotEmpty: not only should it not be empty but it should conform to a specific pattern
I agree with you the NotBlank / NotEmpty example is a bit extreme but I think the first three are perfectly valid and of the same logic as @URL or @Email.
More information about the hibernate-dev
mailing list