Feature Request: Validation
Closed this issue ยท 5 comments
First, thanks for this plugins ๐
As you haven't implemented validation, is there a catch? If not, please, this would be very useful!
And even better if you can provide an easier way to configure basic common things like require, min/max, regex, error/warning messages ๐
For example: qF(name, type, options, validation)
validation
can be a function, that is passed as is:
Rule => Rule.required().max(50).error('Required and max 50 chars.')
Rule => [
Rule.required().max(50).error('Required and max 50 chars.'),
Rule.regex(/^[-a-z0-9]+$/g).error('Only a-z, 0-9, and -.'),
Rule.min(10).warning('Should be at least 10 chars')
]
validation
can be an object:
{ error: 'Required and max 50 chars.', required: true, max: 50 }
validation
can be an array:
[
{ error: 'Required and max 50 chars.', required: true, max: 50 },
{ error: 'Only a-z, 0-9, and -.', regex: /^[-a-z0-9]+$/g },
{ warning: 'Should be at least 10 chars', min: 10 }
]
Quick workaround:
const qFv = (f, validation) => ({ ...f, validation });
qFv(qF('title'), Rule => Rule.required()),
Hey! Great work. I don't really use this library anymore myself but I love that you've done a PR (#2) for the feature, so I'm gonna go merge it!
Thanks. Are you using something else? Or just the plain verbose syntax? ๐คทโโ๏ธ
Hey! Great work. I don't really use this library anymore myself but I love that you've done a PR (#2) for the feature, so I'm gonna go merge it!
Is it still supported? I was about to open an issue related to qF
breaking the sanity graphql deploy
command. ๐
Open away @sandren! I'd still like this library to work even if I'm not still personally using it ๐