Class: CollectionJson::Serializer::Validator

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/collection_json_serializer/validator.rb,
lib/collection_json_serializer/validator/url.rb,
lib/collection_json_serializer/validator/value.rb

Defined Under Namespace

Classes: Url, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support

#extract_value_from, #has_placeholder?, #parse_url, #segments_with_placeholder?, #set_rel

Constructor Details

#initialize(serializer) ⇒ Validator

Returns a new instance of Validator.



8
9
10
11
12
# File 'lib/collection_json_serializer/validator.rb', line 8

def initialize(serializer)
  @serializer = serializer
  @errors = {}
  validate
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/collection_json_serializer/validator.rb', line 6

def errors
  @errors
end

Instance Method Details

#invalid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/collection_json_serializer/validator.rb', line 18

def invalid?
  @errors.any?
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/collection_json_serializer/validator.rb', line 14

def valid?
  !invalid?
end