From: Kerry T. <ke...@to...> - 2001-11-19 18:47:43
|
This is a suggestion for future development. I think it would be a 'nice-to-have' feature. I was looking at Nick Bauman's API and noticed that his RuleResult class holds the error message while FormProc's getMessage method is in the FormElement. It looks to me like this design prevents FormProc from being able to implement multiple rules. For example, I think it would be useful to be able to configure a field like this: <element name="postalcode"> <!-- Rule for making the field required --> <validator type="rule"> <rule>org.formproc.example.RequiredRule</rule> <error lang="en">This field is required</error> </validator> <!-- Rule for validating a Canadian Postal Code --> <validator type="rule"> <rule>org.formproc.example.CanPostalCodeRule</rule> <error lang="en">This is not a valid Canadian Postal Code</error> </validator> <message lang="en">Please enter a valid postal code</message> </element> The first rule would be evaluated, and if the field is blank then the user would be given the "This field is required" message. If the field is entered, but the postal code is invalid, then the second rule is evaluated and he/she would be presented with the invalid postal code message. It also seems logical to me that the error message would be a property of the validator for a particular field. This change might make porting/merging Nick's rules easier as well. Regards, -Kerry -- Kerry Todyruik <ke...@to...> |