aboutsummaryrefslogtreecommitdiff
path: root/src/operations/mixins/password_validations.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/operations/mixins/password_validations.cr')
-rw-r--r--src/operations/mixins/password_validations.cr12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/operations/mixins/password_validations.cr b/src/operations/mixins/password_validations.cr
new file mode 100644
index 0000000..c56b975
--- /dev/null
+++ b/src/operations/mixins/password_validations.cr
@@ -0,0 +1,12 @@
+module PasswordValidations
+ macro included
+ before_save run_password_validations
+ end
+
+ private def run_password_validations
+ validate_required password, password_confirmation
+ validate_confirmation_of password, with: password_confirmation
+ # 72 is a limitation of BCrypt
+ validate_size_of password, min: 6, max: 72
+ end
+end