A collection of GraphQL custom scalar types with fluent API for cleanup, validation, and default values. Version 2.11.0 extends GraphQLScalarType with chainable validators like .length(), .regex(), .trim(), and .base64(). Supports string, number, integer, and custom scalars. Useful for building type-safe GraphQL schemas with built-in sanitization. Compatible with graphql-tools and Apollo. No major updates since 2019, likely in maintenance mode.
npm install graphql-validated-typesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a HexColor scalar type with transformation to uppercase, hex validation, fixed length, and default value.
Ensure cleanups (like .trim()) come before validators to avoid rejecting input with whitespace.
Upgrade to graphql-js v15 or use a newer library like 'graphql-type-json'.
Explicitly handle null values in your resolvers or use GraphQLNonNull with default.
Chain .default() after .toUpperCase() to ensure default value is also uppercased.
Always pass numbers or parse externally if input is string.
new GraphQLValidatedString(...).hex() instead of .hex() on non-instantiated object.
Always provide { name: 'YourType' } when instantiating.Ensure argument is a function that returns value or throws.
Use new GraphQLNonNull(HexColor) if field is required.