Hi, thanks for the reply - I have updated the validation rules in the
model with your suggestion, I get the following errors back for data
that should be valid (ie. allowed)
==
Warning (2): preg_match() [function.preg-match]: No ending delimiter
'^' found [CORE/cake/libs/model/model.php, line 2571]
Notice (8): Undefined offset: 0 [CORE/cake/libs/model/model.php, line
2550]
Warning (512): Could not find validation handler for company_name
[CORE/cake/libs/model/model.php, line 2573]
==
The validation rule should only allow a user to input lower and upper
case letters - no numbers spaces or punctuation. (I'm hoping thats
what my original expressions did!)
The "Account" model now reads as;
==
<?php
class Account extends AppModel {
var $name = 'Account';
var $useDbConfig = 'accounts';
var $validate = array(
'email' => array(
'rule' => 'email',
'message' => 'Email must be valid.',
'allowEmpty' => false
),
'password' => array(
'rule' => array('minlength', 6),
'message' => 'Passwords must be six (6) characters or
more.',
'allowEmpty' => false
),
'first_name' => array(
'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$',
'message' => 'Names can only contain letters.',
'allowEmpty' => false
),
'second_name' => array(
'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$',
'message' => 'Names can only contain letters.',
'allowEmpty' => false
),
'company_name' => array(
'rule' => array('custom' => '(\w(\s)?)+'),
'message' => 'Company names can only contain letters,
numbers and spaces.'
),
/*
'terms_accepted' => array(
'rule' => array('boolean'),
'required' => true,
'message' => 'You must agree to the terms and conditions
and privacy policy.',
)
*/
);
}
?>
==
On Jul 12, 2:39 pm, McBuck DGAF <[email protected]> wrote:
> Instead of:
>
> > 'rule' => array('custom' =>
> > '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*$'),
>
> Could you try:
>
> 'rule' => '^[a-zA-Z]+(([\'\,\.\-][a-zA-Z])?[a-zA-Z]*)*
> $',
>
> If that works, and you use this regular expression more than once, you
> could consider implementing a custom validation rule as described
> here:
>
> http://book.cakephp.org/view/1179/Custom-Validation-Rules
>
> On Jul 11, 5:41 pm, Felix <[email protected]> wrote:
>
>
>
> > Hi, I have an odd validation issue I can't work out.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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