Tuesday, September 16, 2008

Re: Why is the Validation Filters Array Processed Backwards and Returns Conservatively?

> If that's true, how do you explain the behaviour I mentioned above?
> (unique message doesn't display, required message does)?

Because in your example, the validation rule is not handled in the
normal manner. Checking if a field is empty or not is not handled by
the 'allowEmpty' key, and works differently to the normal validation
flow (yeah, it's weird).

For example, with these rules:

var $validate = array(
"name"=>array(
"required"=>array(
"rule"=>array("minLength, 1),
"message"=>"is required",
"required"=>true
),
"need-a"=>array(
"rule"=>"/a/",
"message"=>"must contain an a"
),
"need-b"=>array(
"rule"=>"/b/",
"message"=>"must contain a b"
)
)
);

If you give it "xyz", both the 'need-a' and 'need-b' rules will fail,
and the error message will first be set to "must contain an a" then
overwritten with "must contain a b". If, in the "need-a" rule you add
"last" => true, then the validation for that field will stop after
'need-a' fails and the error message will remain "must contain an a".

hope this makes sense
grigri

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: