class Toolchain::Validations::Validators::Acceptance
Validates the acceptance of an attribute. Accepted values are as follows: `true`, `1` and `“1”`.
@example
class User::Creator validates :terms, acceptance: { message: "the terms of service must be accepted" } end
Public Instance Methods
validate()
click to toggle source
# File lib/toolchain/validations/validators/acceptance.rb, line 15 def validate errors.add(key_path, message || "must be accepted") if not_accepted? end
Private Instance Methods
not_accepted?()
click to toggle source
# File lib/toolchain/validations/validators/acceptance.rb, line 21 def not_accepted? ![1, "1", true].include?(value) end