Hi David,

you probably don't need to extend constraints since those don't contain actual validation rules. They provide meta-data that will be interpreted by for example the validate method and validation rules will be created accordingly.

To add custom validation rules, all you need to do is add the following method in activateValidation:
addRule(your_validationrule_instance).

Your validation rule has to implement the following interface:
http://rifers.org/docs/api/com/uwyn/rife/site/ValidationRule.html

If your rule relates to a bean property, you can extend this abstract base class for convenience: http://rifers.org/docs/api/com/uwyn/rife/site/ PropertyValidationRule.html

Otherwise, this abstract base class will probably provide what you need:
http://rifers.org/docs/api/com/uwyn/rife/site/ AbstractValidationRule.html

I hope this helps.

Best regards,

Geert

I would like to implement custom validation rules for form inputs which go a bit beyond the standard RIFE ones. I can understand how to add a custom error message so that failure of the validation can be reported. What I can't figure out is where the actual rules go. For example, in a user manager
app, I would like to:

(a) test whether password and retyped password are the same and complain if
not.

(b) test that login name is an email address OR one of a fixed list of special
names, and complain if not.

I am using bean constrained properties, so I imagine I ought to be able to define a custom constraint, perhaps by extending ConstrainedProperty to include new methods? I don't see how I would do (a) this way (how to refer to another property to compare with?), though I could imagine (b) is soluble this way, though whether RIFE would register the connection between the custom method and the custom error message without some further code is
doubtful!  I'm missing something - can someone help?

Thanks,

David Herbert.
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users


--
Geert Bevin                       Uwyn bvba
"Use what you need"               Avenue de Scailmont 34
http://www.uwyn.com               7170 Manage, Belgium
gbevin[remove] at uwyn dot com    Tel +32 64 84 80 03

PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net


_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users

Reply via email to