Class: Sinatra::ParamValidator::Parameter::String

Inherits:
Object
  • Object
show all
Includes:
Common, CommonMinMaxLength
Defined in:
lib/sinatra/param_validator/parameter/string.rb

Overview

Validation for strings

Instance Attribute Summary

Attributes included from Common

#coerced, #errors

Instance Method Summary collapse

Methods included from CommonMinMaxLength

#max_length, #min_length

Methods included from Common

#in, #initialize, #is, #nillable, #required, #valid?

Instance Method Details

#format(format_string) ⇒ Object



13
14
15
# File 'lib/sinatra/param_validator/parameter/string.rb', line 13

def format(format_string)
  @errors.push "Parameter must match the format #{format_string}" unless @coerced&.match?(format_string)
end