Class: Philiprehberger::SchemaValidator::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/schema_validator/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, required: true, default: nil, format: nil, in: nil, min: nil, max: nil, of: nil, schema: nil, length: nil, &validator) ⇒ Field

rubocop:disable Metrics/ParameterLists



8
9
10
11
12
13
# File 'lib/philiprehberger/schema_validator/field.rb', line 8

def initialize(name, type, required: true, default: nil, format: nil, in: nil, min: nil, max: nil, # rubocop:disable Metrics/ParameterLists
               of: nil, schema: nil, length: nil, &validator)
  assign_basic_attrs(name, type, required, default, format)
  assign_constraint_attrs(binding.local_variable_get(:in), min, max, of, schema, length)
  @validator = validator
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def default
  @default
end

#formatObject (readonly)

Returns the value of attribute format.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def format
  @format
end

#inObject (readonly)

Returns the value of attribute in.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def in
  @in
end

#lengthObject (readonly)

Returns the value of attribute length.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def length
  @length
end

#maxObject (readonly)

Returns the value of attribute max.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def min
  @min
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def name
  @name
end

#ofObject (readonly)

Returns the value of attribute of.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def of
  @of
end

#schemaObject (readonly)

Returns the value of attribute schema.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def schema
  @schema
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def type
  @type
end

#validatorObject (readonly)

Returns the value of attribute validator.



6
7
8
# File 'lib/philiprehberger/schema_validator/field.rb', line 6

def validator
  @validator
end

Instance Method Details

#required?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/philiprehberger/schema_validator/field.rb', line 15

def required?
  @required
end