Class: RestMyCase::AccusationAttorneys::Format
- Defined in:
- lib/rest_my_case/accusation_attorneys/format.rb
Overview
I DO NOT CLAIM OWNERSHIP OF THIS CODE, THIS CODE WAS TAKEN FROM “ActiveModel” GEM AND ADAPTED TO RUN WITHOUT “ActiveSupport” ORIGINAL SOURCE FILE: ActiveModel::Validations::FormatValidator
Instance Attribute Summary
Attributes inherited from Each
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Each
Methods inherited from Base
Constructor Details
This class inherits a constructor from RestMyCase::AccusationAttorneys::Each
Instance Method Details
#check_validity! ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rest_my_case/accusation_attorneys/format.rb', line 19 def check_validity! unless .include?(:with) ^ .include?(:without) # ^ == xor, or "exclusive or" raise ArgumentError, "Either :with or :without must be supplied (but not both)" end (, :with) (, :without) end |
#validate_each(record, attribute, value) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/rest_my_case/accusation_attorneys/format.rb', line 9 def validate_each(record, attribute, value) if [:with] regexp = option_call(record, :with) record_error(record, attribute, :with, value) if value.to_s !~ regexp elsif [:without] regexp = option_call(record, :without) record_error(record, attribute, :without, value) if value.to_s =~ regexp end end |