class GraphQL::Schema::Validator::FormatValidator

Use this to assert that string values match (or don’t match) the given RegExp.

Examples

Example: requiring input to match a pattern

argument :handle, String, required: true,
  validates: { format: { with: /\A[a-z0-9_]+\Z/ } }

Example: reject inputs that match a pattern

argument :word_that_doesnt_begin_with_a_vowel, String, required: true,
  validates: { format: { without: /\A[aeiou]/ } }

# It's pretty hard to come up with a legitimate use case for `without:`