module DTOSchema::Validators::Parse
Public Class Methods
parse_validator(spec, schema)
click to toggle source
# File lib/dto_schema/validators.rb, line 265 def self.parse_validator (spec, schema) return PrimitiveValidator.new(spec) if primitive? spec return spec if validator? spec ValidatorReference.new(schema, spec) if reference? spec end
primitive?(spec)
click to toggle source
# File lib/dto_schema/validators.rb, line 271 def self.primitive? (spec) spec.is_a?(Class) && (spec <= Numeric || spec <= String) end
reference?(spec)
click to toggle source
# File lib/dto_schema/validators.rb, line 279 def self.reference? (spec) spec.is_a? Symbol end
validator?(spec)
click to toggle source
# File lib/dto_schema/validators.rb, line 275 def self.validator? (spec) spec.is_a? BaseValidator end