Skip to content

🎁 Validate anything in context

Compare
Choose a tag to compare
@marshallswain marshallswain released this 18 Feb 17:46
· 46 commits to master since this release

Use the getContext and setContext methods to validate anything in context. 😎

const options = {
  convert: true,
  getContext(context) {
    return context.params.query;
  },
  setContext(context, newValues) {
    Object.assign(context.params.query, newValues);
  },
}
const hooks = {
  before: {
    get: [
      validate.form(schema, options)
    ]
  }
}