@author Martin Kihlgren @since 0.9
# File lib/dm-validations/validators/acceptance_validator.rb, line 7 7: def initialize(field_name, options = {}) 8: super 9: 10: @options[:allow_nil] = true unless @options.key?(:allow_nil) 11: 12: @options[:accept] ||= [ '1', 1, 'true', true, 't' ] 13: @options[:accept] = Array(@options[:accept]) 14: end
# File lib/dm-validations/validators/acceptance_validator.rb, line 16 16: def call(target) 17: return true if valid?(target) 18: 19: error_message = ( 20: @options[:message] || ValidationErrors.default_error_message( 21: :accepted, field_name 22: ) 23: ) 24: add_error(target, error_message, field_name) 25: 26: false 27: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.