Package graphql.validation.rules
Class ValidationRules
- java.lang.Object
-
- graphql.validation.rules.ValidationRules
-
@PublicApi public class ValidationRules extends java.lang.ObjectValidationRulesis a holder of validation rules and you can then pass it field and arguments and narrow down the list of actual rules that apply to those fields and arguments.It also allows you to run the appropriate rules via the
runValidationRules(graphql.schema.DataFetchingEnvironment)method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classValidationRules.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TargetedValidationRulesbuildRulesFor(graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)java.util.LocalegetLocale()MessageInterpolatorgetMessageInterpolator()OnValidationErrorStrategygetOnValidationErrorStrategy()java.util.List<ValidationRule>getRules()java.util.List<ValidationRule>getRulesFor(graphql.schema.GraphQLArgument fieldArg, graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)java.util.List<ValidationRule>getRulesFor(graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)static ValidationRules.BuildernewValidationRules()A builder of validation rules.java.util.List<graphql.GraphQLError>runValidationRules(graphql.schema.DataFetchingEnvironment env)This helper method will run the validation rules that apply to the providedDataFetchingEnvironment
-
-
-
Method Detail
-
getMessageInterpolator
public MessageInterpolator getMessageInterpolator()
-
getLocale
public java.util.Locale getLocale()
-
getRules
public java.util.List<ValidationRule> getRules()
-
getOnValidationErrorStrategy
public OnValidationErrorStrategy getOnValidationErrorStrategy()
-
buildRulesFor
public TargetedValidationRules buildRulesFor(graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)
-
getRulesFor
public java.util.List<ValidationRule> getRulesFor(graphql.schema.GraphQLArgument fieldArg, graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)
-
getRulesFor
public java.util.List<ValidationRule> getRulesFor(graphql.schema.GraphQLFieldDefinition fieldDefinition, graphql.schema.GraphQLFieldsContainer fieldsContainer)
-
runValidationRules
public java.util.List<graphql.GraphQLError> runValidationRules(graphql.schema.DataFetchingEnvironment env)
This helper method will run the validation rules that apply to the providedDataFetchingEnvironment- Parameters:
env- the data fetching environment- Returns:
- a list of zero or more input data validation errors
-
newValidationRules
public static ValidationRules.Builder newValidationRules()
A builder of validation rules. By default the SDL @directive rules fromDirectiveConstraints.STANDARD_CONSTRAINTSare included but you can add extra rules or callValidationRules.Builder.clearRules()to start afresh.- Returns:
- a new builder of rules
-
-