mardi 27 novembre 2018

Devise gem - Do not allow special character in password

I have used devise gem in rails application. password format for validation I found is

PASSWORD_FORMAT_USED_CURRENTLY = /\A
  (?=.{10,})          # Must contain 10 or more characters
  (?=.*\d)           # Must contain a digit
  (?=.*[a-z])        # Must contain a lower case character
  (?=.*[A-Z])        # Must contain an upper case character
  (?=.*[[:^alnum:]]) # Must contain a symbol
/x

It works fine but I want two requirements to be fulfilled for my password 1) password must contain at least 6 letters ( it can be capital letters, small letters, digits or a combination of all ).

 PASSWORD_FORMAT = /\A
  (?=.{6,})          # Must contain 6 or more characters      
/x

2) the second criteria is that the password should not contain any special characters.

I don't know how to achieve this what I found is only that how can I make compulsory the presence of special characters but not vice versa.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire