Welcome to the Cookbook

loading...

4.1.4.15 minLength

This rule ensures that the data meets a minimum length requirement.

var $validate = array(
    'login' => array(
        'rule' => array('minLength', 8),  
        'message' => 'Usernames must be at least 8 characters long.'
    )
);
  1. var $validate = array(
  2. 'login' => array(
  3. 'rule' => array('minLength', 8),
  4. 'message' => 'Usernames must be at least 8 characters long.'
  5. )
  6. );

The length here is "the number of bytes in the string representation of the data". Be careful that it may be larger than the number of characters when handling non-ASCII characters.