Class NameValidation
- java.lang.Object
-
- io.smallrye.graphql.client.core.utils.validation.NameValidation
-
public class NameValidation extends Object
This class provides utility methods for validating names according to the GraphQL specification.- See Also:
- https://spec.graphql.org/draft/#Name
-
-
Constructor Summary
Constructors Constructor Description NameValidation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringvalidateFieldName(String fieldName)Validates the given field name, allowing at most one colon that is not at the beginning or end for alias.static StringvalidateFragmentName(String name)Validates a GraphQL fragment name and returns it.static StringvalidateName(String name)Validates a GraphQL name and returns it.static StringvalidateNameAllowEmpty(String name)Validates a GraphQL name and returns it.
-
-
-
Method Detail
-
validateNameAllowEmpty
public static String validateNameAllowEmpty(String name)
Validates a GraphQL name and returns it. Throws an IllegalArgumentException if the name is null or invalid. Allows empty string "" as a valid input.- Parameters:
name- the name to validate- Returns:
- the validated name
- Throws:
IllegalArgumentException- if the name is null or invalid
-
validateFragmentName
public static String validateFragmentName(String name)
Validates a GraphQL fragment name and returns it. Throws an IllegalArgumentException if the name is null, invalid or is equal to the reserved word "on".- Parameters:
name- the name to validate- Returns:
- the validated name
- Throws:
IllegalArgumentException- if the name is null, invalid or is equal to the reserved word "on"- See Also:
- https://spec.graphql.org/draft/#sec-Language.Fragments
-
validateName
public static String validateName(String name)
Validates a GraphQL name and returns it. Throws an IllegalArgumentException if the name is null or invalid. Does not allow empty string "" as a valid input.- Parameters:
name- the name to validate- Returns:
- the validated name
- Throws:
IllegalArgumentException- if the name is null, invalid or empty
-
validateFieldName
public static String validateFieldName(String fieldName)
Validates the given field name, allowing at most one colon that is not at the beginning or end for alias.- Parameters:
fieldName- the field name to validate- Returns:
- the validated field name
- Throws:
IllegalArgumentException- if the field name is null or invalid- See Also:
- https://spec.graphql.org/draft/#sec-Language.Fields
-
-