⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


How to use setRule / setRules in password validation Enterprise Edition

Password Validation setRules

  • Please log in to reply
2 replies to this topic

#1 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 05 June 2017 - 01:34 AM

Regarding the confirm password. I cannot determine how to use password validation.
In the community edition I do password validation by:
 
$crud->set_rules('u_Pwd', 'Password', 'min_length[3]|max_length[20]');
$crud->set_rules('u_Cpass', 'Password Confirmation', 'matches[u_Pwd]|md5');
 
I tried doing it in the enterprise edition and generated an error upon save.
I also tried checking the valitron website and still cannot figure it out. Please help me understand on how to do it.
Please refer to the attached photo:
image.png

 

                



#2 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 200 posts

Posted 07 June 2017 - 03:48 AM

I finally figure it out using the links:

1. Valitron: https://github.com/vlucas/valitron

2. API & Function: https://www.groceryc...n-list/setRules

 

In my case I used a custom regex to achieve what I want:

 
$crud->setRules(
   [
       [
           'fieldName' => 'u_Pwd',
           'rule' => 'regex',
           'parameters'=> '/^[a-z\d\-_\s]+$/i'
           // Allow A-Z, 0-9, dash, underscore and space
       ],
       [
           'fieldName' => 'u_Pwd',
           'rule' => 'lengthMin',
           'parameters'=> '3'
       ],
       [
           'fieldName' => 'u_Cpass',
           'rule' => 'equals',
           'parameters'=> 'u_Pwd'
       ],
   ]
);

 

I just hope it helps someone too. Cheers!  :)



#3 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,166 posts

Posted 13 June 2017 - 03:19 AM

I am glad that you could figure out the solution from the documentation :)

 

Thanks for sharing that knowledge






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users