Class SimpleFieldValidation
- java.lang.Object
-
- graphql.execution.instrumentation.fieldvalidation.SimpleFieldValidation
-
- All Implemented Interfaces:
FieldValidation
@PublicApi public class SimpleFieldValidation extends java.lang.Object implements FieldValidation
This very simple field validation will run the supplied function for a given field path and if it returns an error it will be added to the list of problems. UseaddRule(ResultPath, java.util.function.BiFunction)
to supply the rule callbacks where you implement your specific business logic
-
-
Constructor Summary
Constructors Constructor Description SimpleFieldValidation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleFieldValidation
addRule(ResultPath fieldPath, java.util.function.BiFunction<FieldAndArguments,FieldValidationEnvironment,java.util.Optional<GraphQLError>> rule)
Adds the rule against the field address path.java.util.List<GraphQLError>
validateFields(FieldValidationEnvironment validationEnvironment)
This is called to validate the fields and their arguments
-
-
-
Method Detail
-
addRule
public SimpleFieldValidation addRule(ResultPath fieldPath, java.util.function.BiFunction<FieldAndArguments,FieldValidationEnvironment,java.util.Optional<GraphQLError>> rule)
Adds the rule against the field address path. If the rule returns an error, it will be added to the list of errors- Parameters:
fieldPath
- the path to the fieldrule
- the rule function- Returns:
- this validator
-
validateFields
public java.util.List<GraphQLError> validateFields(FieldValidationEnvironment validationEnvironment)
Description copied from interface:FieldValidation
This is called to validate the fields and their arguments- Specified by:
validateFields
in interfaceFieldValidation
- Parameters:
validationEnvironment
- the validation environment- Returns:
- a list of errors. If this is non empty then the query will not execute.
-
-