Include validation helpers
thosakwe opened this issue · comments
Tobe Osakwe commented
*This issue was automatically moved to: angel-dart/angel#202.
Tobe Osakwe commented
As of angel_validate
v3, the way to validate things is now to use the type-safe Field
and Form
API's, so it might end up looking like this:
field(
'createPost',
resolve: validateGraphQL(
Form(fields: [
TextField('name').match(maxLength(255),
TextField('text'),
ListField('tags', isRequired: false).ofStrings(),
]),
resolveViaServiceCreate(postService),
),
)
// There should also be a way to use a `Field` to read straight from GraphQL inputs:
var name = await nameField.readFromMap(inputs);
Because of the new major version of validate, this would be in a later version.