Back
validatesLengthOf()
Validates that the value of the specified property matches the length requirements supplied.
Use the exactly
, maximum
, minimum
and within
arguments to specify the length requirements.
// Make sure that the `firstname` and `lastName` properties are not more than // 50 characters and use square brackets to dynamically insert the property // name when the error message is displayed to the user. (The `firstName` // property will be displayed as "first name".) validatesLengthOf( properties="firstName,lastName", maximum=50, message="Please shorten your [property] please (50 characters max)." ); // Make sure that the `password` property is between 4 and 15 characters validatesLengthOf( property="password", within="4,20", message="The password length must be between 4 and 20 characters." );
Copied!