class Errapi::Validations::Inclusion
Constants
- OPTIONS
- OPTIONS_DESCRIPTION
Public Class Methods
new(options = {})
click to toggle source
# File lib/errapi/validations/inclusion.rb, line 11 def initialize options = {} unless key = exactly_one_option?(OPTIONS, options) raise ArgumentError, "Either :in or :within must be supplied (but not both)." end @delimiter = options[key] check_delimiter! OPTIONS_DESCRIPTION end
Public Instance Methods
validate(value, context, options = {})
click to toggle source
# File lib/errapi/validations/inclusion.rb, line 20 def validate value, context, options = {} allowed_values = members OPTIONS_DESCRIPTION, options unless include? allowed_values, value context.add_error reason: :not_included, check_value: allowed_values end end