How is it possible to create a function in EDB PostgreSQL to check the password?
The password should contain:
- at least 1 upper case
- at least 1 lower case
- at least 1 digit
- at least 8 characters long
- at least 1 special character
So far I searched and got
CREATE OR REPLACE FUNCTION verify_password(user_name varchar2, new_password varchar2, old_password varchar2)
RETURN boolean IMMUTABLE
IS
BEGIN
IF (length(new_password) < 5)
THEN
raise_application_error(-20001, 'too short');
END IF;
IF substring(new_password FROM old_password) IS NOT NULL
THEN
raise_application_error(-20002, 'includes old password');
END IF;
RETURN true;
END;
Above functions works fine but I am not able to add checks for uppercase, lowercase and special character.
If I add lines on checks for uppercase, lowercase and special character I am able to create the function but when password checks comes in it does not seem to work.