Class: Sinatra::ParamValidator::Rule::OneOf
- Inherits:
-
Object
- Object
- Sinatra::ParamValidator::Rule::OneOf
- Includes:
- Common
- Defined in:
- lib/sinatra/param_validator/rule/one_of.rb
Overview
Rule to enforce only one of the given params has been given
Instance Attribute Summary
Attributes included from Common
Instance Method Summary collapse
Methods included from Common
Instance Method Details
#validate ⇒ Object
12 13 14 15 |
# File 'lib/sinatra/param_validator/rule/one_of.rb', line 12 def validate @errors.push "Only one of [#{@fields.join ', '}] is allowed" if count > 1 @errors.push "One of [#{@fields.join ', '}] must be provided" if count < 1 end |