[rules-users] Running Rules on Form fields

Christie, Blair blair.christie at cgi.com
Thu Feb 21 10:33:24 EST 2008


I want to be able to validate the fields on a form using the same rules
that are used to validate the domain object that represents those

Rules ..without having to check each single field  that is input with
the idea to be able to validate a single field without having to create
the whole domain 

Object. 

 

Example: 

 

If we have a domain object say

 

            Patron

String Name

                        String phoneNumber

 

And you have a form with the fields represented as Strings in a request.

 

            Name

            PhoneNumber 

 

And if the user enters his phone number I just want to run the rule
about phonenumber without firing the rule for name. 

 

The first idea was to create a class for each form field which would
leverage the power of the rule engine for example: 

 

When

            Patron(phoneNumber not matches " \(?\d{3}\)?
?\d{3}[-.]\d{4}") 

||

      PhoneNumber(value not matches " \(?\d{3}\)? ?\d{3}[-.]\d{4}"

Then

      InsertLogical(Message("Bad Phone")

 

But that would mean creating a class for each field, which just seems
wrong. 


Is there a better design? 

 

 

 

Blair Christie

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080221/662edfcf/attachment.html 


More information about the rules-users mailing list