$crud->set_rules('u_Pwd', 'Password', 'min_length[3]|max_length[20]'); $crud->set_rules('u_Cpass', 'Password Confirmation', 'matches[u_Pwd]|md5');
⚠ In case you've missed it, we have migrated 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 is an archived forum. ⚠
Posted 05 June 2017 - 01:34 AM
$crud->set_rules('u_Pwd', 'Password', 'min_length[3]|max_length[20]'); $crud->set_rules('u_Cpass', 'Password Confirmation', 'matches[u_Pwd]|md5');
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.grocerycrud.com/enterprise/api-and-function-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! :)
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