Class: GraphQL::StaticValidation::LiteralValidator
- Inherits:
-
Object
- Object
- GraphQL::StaticValidation::LiteralValidator
- Defined in:
- lib/graphql/static_validation/literal_validator.rb
Overview
Test whether ast_value
is a valid input for type
Instance Method Summary collapse
-
#initialize(context:) ⇒ LiteralValidator
constructor
A new instance of LiteralValidator.
- #validate(ast_value, type) ⇒ Object
Constructor Details
#initialize(context:) ⇒ LiteralValidator
Returns a new instance of LiteralValidator.
6 7 8 9 10 11 |
# File 'lib/graphql/static_validation/literal_validator.rb', line 6 def initialize(context:) @context = context @types = context.types @invalid_response = GraphQL::Query::InputValidationResult.new(valid: false, problems: []) @valid_response = GraphQL::Query::InputValidationResult.new(valid: true, problems: []) end |
Instance Method Details
#validate(ast_value, type) ⇒ Object
13 14 15 16 17 |
# File 'lib/graphql/static_validation/literal_validator.rb', line 13 def validate(ast_value, type) catch(:invalid) do recursively_validate(ast_value, type) end end |