# Password validation

**URL:** <https://discourse.cakephp.org/t/password-validation/9703>\
**Category:** Need Help\
**Created:** [September 9, 2021, 10:24am UTC](https://discourse.cakephp.org/t/password-validation/9703 "2021-09-09T10:24:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![khairul](https://avatars.discourse-cdn.com/v4/letter/k/a88e4f/32.png) [@khairul](https://discourse.cakephp.org/u/khairul)\
**Post date:** [September 9, 2021, 10:24am UTC](https://discourse.cakephp.org/t/password-validation/9703/1 "2021-09-09T10:24:50Z")

</div>

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

```auto
	'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.'
			)

		),

```

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [September 19, 2021, 7:46pm UTC](https://discourse.cakephp.org/t/password-validation/9703/2 "2021-09-19T19:46:46Z")

</div>

Looking at [Data Validation - 2.x](https://book.cakephp.org/2/en/models/data-validation.html#custom-regular-expression-validation) your last rule seems off.

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

```

should be more like

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

```

or according to [Data Validation - 2.x](https://book.cakephp.org/2/en/models/data-validation.html#Validation::customs:)

```auto
'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 😉 )

---

<div class="post-metadata">

**Author:** ![khairul](https://avatars.discourse-cdn.com/v4/letter/k/a88e4f/32.png) [@khairul](https://discourse.cakephp.org/u/khairul)\
**Post date:** [September 22, 2021, 3:52am UTC](https://discourse.cakephp.org/t/password-validation/9703/3 "2021-09-22T03:52:18Z")

</div>

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