Created
January 8, 2019 16:22
-
-
Save Samuyi/42c7ec34248825cc66fc71a671202365 to your computer and use it in GitHub Desktop.
passwd function for my article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION passwd_func() | |
RETURNS TRIGGER | |
AS $$ | |
BEGIN | |
IF length(NEW.password) < 10 OR NEW.password IS NULL THEN | |
RAISE EXCEPTION 'password cannot be less than 10 characters'; | |
END IF; | |
IF NEW.NAME IS NULL THEN | |
RAISE EXCEPTION 'Name cannot be NULL'; | |
END IF; | |
RETURN NEW; | |
END; | |
$$ | |
LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment