instance method
validate
Ruby on Rails edge
Since edgeSignature
validate(record, attribute)
Validates the password and adds error to the record in the given attribute. BCrypt has a maximum input size, so we need to validate it.
Parameters
-
recordreq -
attributereq
Source
# File activemodel/lib/active_model/secure_password/bcrypt_password.rb, line 38
def validate(record, attribute)
password = record.public_send(attribute)
if password.present?
record.errors.add(attribute, :password_too_long) if password.bytesize > MAX_PASSWORD_LENGTH_ALLOWED
end
end
Defined in activemodel/lib/active_model/secure_password/bcrypt_password.rb line 38
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::SecurePassword::BCryptPassword