Class: GQLi::Validation

Inherits:
Object
  • Object
show all
Defined in:
lib/gqli/validation.rb

Overview

Validations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema, root) ⇒ Validation

Returns a new instance of Validation.



8
9
10
11
12
13
14
# File 'lib/gqli/validation.rb', line 8

def initialize(schema, root)
  @schema = schema
  @root = root
  @errors = []

  validate
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/gqli/validation.rb', line 6

def errors
  @errors
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/gqli/validation.rb', line 6

def root
  @root
end

#schemaObject (readonly)

Returns the value of attribute schema.



6
7
8
# File 'lib/gqli/validation.rb', line 6

def schema
  @schema
end

Instance Method Details

#valid?Boolean

Returns wether the query is valid or not

Returns:

  • (Boolean)


17
18
19
# File 'lib/gqli/validation.rb', line 17

def valid?
  errors.empty?
end