I'm trying to figure out how to set validation in one of my models
(v1.2) and I don't understand the docs. In this case, I want to start
simple and just indicate that in my Address model, street_address_1 is
required.  In the code below ("borrowed" from the book), I don't
understand the breakdown. The way I read it is clearly incorrect
because it looks like the 'alphaNumeric' rule is required and that
doesn't make any sense to me.  I also can't find any built-in
"required" rule (though I do so notEmpty, minLength, etc.).

If I were to simplify this example and simple ask that the login field
be required, how would I do that?

<?php
class User extends AppModel {
    var $name = 'User';
    var $validate = array(
        'login' => array(
            'alphaNumeric' => array(
                'rule' => 'alphaNumeric',
                'required' => true,
                'message' => 'Alphabets and numbers only'
                ),
            'between' => array(
                'rule' => array('between', 5, 15),
                'message' => 'Between 5 to 15 characters'
            )
        ),
        'password' => array(
            'rule' => array('minLength', '8'),
            'message' => 'Mimimum 8 characters long'
        ),
        'email' => 'email',
        'born' => array(
            'rule' => 'date',
            'message' => 'Enter a valid date',
            'allowEmpty' => true
        )
    );
}
?>

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

Reply via email to