Password validation

hye good day to all my cakephp master. I am new to codes. Just working about 6 months. i got a problem with the password validation. which is requirement for password is 8 character. 1 symbol and 1 number. what i have done is show as below. but not succes, only 8 character just success not for 1 number and 1 symbol. Please help me. give some suggestion to resolve this issue.
cakephp 2.x

	'password' => array(
			'lengthBetween'=>array(
			'rule' => array('lengthBetween', 8, 20),
			'message' => 'Passwords must be at least 8 characters long and not longer then 20 characters',
			),

			'Numeric'=>array(
			'rule' => array('Numeric', 1),
			'required'=>true,
			'allowEmpty'=>false,
			'message' => 'number kena ad 1',
			
			),

			'custom'=>array(
			'rule' => 'custom','/^[\W]+$/',1,
			'allowEmpty'=>false,
			'message' => 'Password must have at least one special character.'
			)

		),

Looking at Data Validation - 2.x your last rule seems off.

'custom'=>array(
	'rule' => 'custom','/^[\W]+$/',1,
	'allowEmpty'=>false,
	'message' => 'Password must have at least one special character.'
)

should be more like

'custom'=>array(
	'rule' => '/^[\W]+$/',
	'allowEmpty'=>false,
	'message' => 'Password must have at least one special character.'
)

or according to Data Validation - 2.x

'custom'=>array(
	'rule' => array('custom', '/^[\W]+$/'),
	'allowEmpty'=>false,
	'message' => 'Password must have at least one special character.'
)

But I never used CakePHP 2 (and it is EOL, so you should look into an upgrade :wink: )

1 Like

Already try this code…need to insert 8 special character for pwd…hihi