You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'd like to define some scalars that are for example positive integers limited to values between 0 to 6 (for a weekday index).
Describe the solution you'd like
It seems it would be possible to expose a factory method that could return a custom scalar with custom validation.
For example:
import{PositiveIntResolver,CustomStringResolver}from'graphql-scalars';constmyResolverMap={Weekday: PositiveIntResolver.create({name: "Weekday",description: "A value between 0 (Monday) and 6 (Sunday)",min: 0,max: 6}),CustomId: CustomStringResolver.create({name: "CustomId",description: "A string with custom validation",validation: /some-regex/})...
This could be useful for us as well to implement things like a Percentage scalar that accepts float numbers between 0 and 100. Not too difficult to implement from scratch, but we would have used graphql-scalars if there was a simple helper for this like the one mentioned above:
Is your feature request related to a problem? Please describe.
I'd like to define some scalars that are for example positive integers limited to values between 0 to 6 (for a weekday index).
Describe the solution you'd like
It seems it would be possible to expose a factory method that could return a custom scalar with custom validation.
For example:
Describe alternatives you've considered
Manually defining my own scalars.
Additional context
Edit: it appears this is already a thing for regex validation: https://github.com/Urigo/graphql-scalars#using-the-regularexpression-scalar
Would really like it for numeric values as well.
The text was updated successfully, but these errors were encountered: