I have written the following function:
CREATE FUNCTION Validate_Password_Hash() RETURNS trigger AS $$
BEGIN
IF (NEW.Password ~* '^[a-f0-9]{64}$')
THEN
RAISE EXCEPTION 'The password hash is invalid! Please use SHA-256. You tried to insert: %', NEW.Password;
END IF;
RETURN NEW;
END;
$$ LANGUAGE PLPGSQL;
And I attach it to a trigger to fire before an INSERT. However, even if a provide a valid SHA-256 hash, the exception still gets raised, which implies the hash doesn't match the pattern. What could possibly be the problem here?