|
From: Thomas V. de V. <tho...@ac...> - 2005-09-13 06:48:07
|
I wasn't familiar with Valang. It make sense to keep this in line with thei=
r=20
rule definitions. Are they checking the validity of the rules at run-time,=
=20
when the application context loads?=20
On 9/13/05, Oliver Hutchison <Ol...@ou...> wrote:
>=20
>=20
>=20
> > Basically we could do something like this:
> >
> >
> > public @interface Validate {
> > String constraint();
> > String code();
> > String message();
> > String[] arguments();
> > }
>=20
> I personally think it would be nicer to implement the annotation in a
> way that is consistent with the rule definitions used by
> ValangValidatorFactoryBean:
>=20
> public @interface Validate {
> String valang();
> }
>=20
> public class MyClass {
>=20
> @Validate("? not blank : 'First name should not be blank' :
> 'firstName_blank'")
> public String getFirstName() { return this.firstName; }
>=20
> Also how would you deal with validating nested objects? For instance,
> when editing contact details, our website will present the user with a
> list of states and also with the option of entering in an alternative
> state not in the list using a text field. Usually we bind directly onto
> our domain object but because we have introduced an additional field I
> create a form object that provides an accessor for the domain object and
> for the additional field and then bind what I can directly to the domain
> object and the additional fields onto the form object:
>=20
> class ContactForm {
> Contact contact;
> String otherState;
>=20
> // where possible bind directly to this domain object
> getContact() { return contact;}
>=20
> @Validate("? is not blank && contact.state is not blank :
> 'Please select or enter a state but not both')
> String getOtherState() { return otherState; }
> void setOtherState(String otherState) {this.otherState =3D
> otherState; }
> }
>=20
> How would you tell the annotation driven validator that it must also
> validate the Contact object? Would we need an additional annotation?
>=20
> public @interface ValidateNested {
> }
>=20
> class ContactForm {
> Contact contact;
> String otherState;
>=20
> @ValidateNested
> getContact() { return contact;}
> ...
>=20
>=20
> Ollie
>=20
>=20
>=20
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle=20
> Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & Q=
A
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|