Package graphql.validation.rules
Interface ValidationRule
-
- All Known Subinterfaces:
DirectiveConstraint
- All Known Implementing Classes:
AbstractDirectiveConstraint,AbstractNotEmptyRule,AbstractSizeConstraint,AssertFalseConstraint,AssertTrueConstraint,ContainerNotEmptyConstraint,ContainerSizeConstraint,DecimalMaxConstraint,DecimalMinConstraint,DigitsConstraint,ExpressionConstraint,MaxConstraint,MinConstraint,NegativeConstraint,NegativeOrZeroConstraint,NotBlankRule,NotEmptyRule,PatternConstraint,PositiveConstraint,PositiveOrZeroConstraint,RangeConstraint,SizeConstraint
@PublicSpi public interface ValidationRuleA validation rule is code that can be applied inside aValidationEnvironmentand produce a list of zero or moreGraphQLErrors as validation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanappliesTo(graphql.schema.GraphQLArgument argument, graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)This is called to work out if this rule applies to the argument of a specified fieldbooleanappliesTo(graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)This is called to work out if this rule applies to a specified fieldjava.util.List<graphql.GraphQLError>runValidation(ValidationEnvironment validationEnvironment)This is called to runs the rule.
-
-
-
Method Detail
-
appliesTo
boolean appliesTo(graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)This is called to work out if this rule applies to a specified field- Parameters:
fieldDefinition- the field to checkfieldsContainer- the field container- Returns:
- true if this rule applies to the field
-
appliesTo
boolean appliesTo(graphql.schema.GraphQLArgument argument, graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)This is called to work out if this rule applies to the argument of a specified field- Parameters:
argument- the argument to checkfieldDefinition- the field to checkfieldsContainer- the field container- Returns:
- true if this rule applies to the argument of the field field
-
runValidation
java.util.List<graphql.GraphQLError> runValidation(ValidationEnvironment validationEnvironment)
This is called to runs the rule. A rule maybe invoked MULTIPLE times per field. It will be invoked once for the original field, then invoked for each of the arguments on a field and then if the input types are complex ones such asGraphQLInputObjectTypethen it will be invoked for each attribute of that type.A rule should consult
ValidationEnvironment.getValidatedElement()to check what element is being validated. If the rule does not handle that type of element, simply return an empty list of errors.- Parameters:
validationEnvironment- the validation environment- Returns:
- a non null list of errors where emptyList() means its valid
-
-