| Module | DataMapper::Validate::ValidatesIsAccepted |
| In: |
lib/dm-validations/validators/acceptance_validator.rb
|
Validates that the attributes‘s value is in the set of accepted values.
@option :allow_nil<Boolean> true if nil is allowed, false if nil is not
allowed. Default is true.
@option :accept<Array> a list of accepted values.
Default are ["1", 1, "true", true, "t"]).
@example [Usage]
require 'dm-validations'
class Page
include DataMapper::Resource
property :license_agreement_accepted, String
property :terms_accepted, String
validates_is_accepted :license_agreement, :accept => "1"
validates_is_accepted :terms_accepted, :allow_nil => false
# a call to valid? will return false unless:
# license_agreement is nil or "1"
# and
# terms_accepted is one of ["1", 1, "true", true, "t"]