SpamBlocker
Spam Blocker is a CakePHP Behavior that automatically before after a comment is made. Each comment is tested upon a point system to determine if it should be approved, set to pending (high points), or marked as spam / deleted (low points).
Begins With
Checks to see if the first character is either a number or letter when validating in the Model.
Function: beginsWith()
Category: CakePHP
Views: 1,434
Permalink -
Tinylink
/** * Checks to see if the first character is either a number or letter when validating in the Model * @param array $data * @param string $type * @return boolean */ function beginsWith($data, $type) { $data = array_values($data); $first = substr($data[0], 0, 1); if ($type == 'number') { return (is_numeric($first)) ? true : false; } else { return (!is_numeric($first)) ? true : false; } }
Example Usage
var $validate = array(
'password' => array(
'rule' => array('beginsWith', 'letter'),
'message' => 'Your passwords must begin with a letter'
)
);