[rules-users] Help with my understanding

Andrew Robinson andrew.rw.robinson at gmail.com
Wed Dec 19 12:20:29 EST 2007


although it looks like you may want "not matches" instead?

On Dec 19, 2007 10:19 AM, Andrew Robinson <andrew.rw.robinson at gmail.com> wrote:
> How about this:
>
> rule "Valid Format"
> when
>   $status : RuleResult()
>   Identifier(value matches "^([0-9]{9})$")
> then
>   $status.addErrorMessage("Identifier does not match required format");
> end
>
> http://downloads.jboss.com/drools/docs/4.0.3.15993.GA/html_single/index.html#d0e3318
>
>
> On Dec 19, 2007 9:48 AM,  <John.Dubchak at wellsfargo.com> wrote:
> >
> >
> >
> >
> > Hi,
> >
> >
> >
> > We are using Jboss-rules 3.0.5 and I have written a simple rule:
> >
> >
> >
> > rule "Valid Format"
> >
> >
> >
> >        when
> >
> >               $status : RuleResult()
> >
> >               $id : Identifier()
> >
> >
> >
> >               eval ($id.getValue() != null)
> >
> >               eval (!$id.getValue().matches("^([0-9]{9})$"))
> >
> >        then
> >
> >               $status.addErrorMessage("Identifier does not match required
> > format");
> >
> >
> >
> > end
> >
> >
> >
> > In my unit test, I create an instance of the Identifier object and do not
> > set the Value, therefore it is null by default.  I have an earlier rule that
> > checks for this null value and places an error message in the result object
> > appropriately.  I would expect this error to fail and not see this error
> > message in the result, but instead see the missing value error message.  The
> > problem is that I see both.
> >
> >
> >
> > It appears as though the eval null check is failing.  Am I misunderstanding
> > how this rule should work?
> >
> >
> >
> > Any insight and/or answers are really appreciated.
> >
> >
> >
> > Thanks,
> >  John
> >
> >
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>



More information about the rules-users mailing list