instance method validate

Ruby on Rails edge

Since edge

Signature

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

record req
attribute req
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

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close