|
From: Steven D. <ste...@in...> - 2005-09-12 13:33:08
|
I've had a couple of requests now to include support for annotations.
Basically we could do something like this:
public @interface Validate {
String constraint();
String code();
String message();
String[] arguments();
}
So you could do:
package test;
public class MyClass {
private String firstName = null;
@Validate(
constraint = "? not blank",
code = "firstName_blank"
)
public String getFirstName() { return this.firstName; }
public void setFirstName(String firstName) { this.firstName =
firstName; }
private String lastName = null;
@Validate("? not blank") // would use code:
test.MyClass_lastName_invalid
public String getLastName() { return this.lastName; }
public void setLastName(String lastName) { this.lastName =
lastName; }
}
Any thoughts on this?
Steven Devijver
Senior consultant
@ Interface21
ste...@in...
On 12 Sep 2005, at 14:51, Sean Miller wrote:
> This looks like a really neat option for single-field validations;
> is there an obvious way of handling multi-field validations as
> annotations, like
>
> collision : (firstName is not blank or lastName is not blank) and
> userid is not blank : 'Fill in either name or id'
>
> Cheers,
> Sean Miller.
>
> Thomas Van de Velde wrote:
>
>
>
>
>
>> I am wondering if it'd make sense to have the validation rules
>> defined as annotations.
>> e.g.
>>
>> @RequiredField
>> @EmailAddress
>>
>> I've worked with forms that contains 2 000 + fields and
>> maintaining external XML files is really cumbersome in such a
>> case? Any thoughts, pros/cons?
>>
>>
>>
>>
>
>
>
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams *
> Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/
> bsce5sf
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
>
>
>
|