Guides  ›  Validations  ›  Schemas ← PREV NEXT →

Schemas

A route schema validates state.req.body.params before the handler.

module.exports = {
  paths: '/users',
  methods: 'POST',
  schema: {
    email: { required: true, is: 'email' }
  },
  handler: function (state) {
    return state.jarpc({ ok: true })
  }
}

Invalid input returns { ok: false, message, fields } with the request ID. Use schema: 'users/create' to load app/schemas/users/create.js.

Next: Required fields →

Tools for business systems.