Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Releases: feathersjs-ecosystem/validate-joi

Export Typescript Definitions

Choose a tag to compare

@toddbluhm toddbluhm released this 23 Dec 04:55
e914d74
  • Change: Updated and exported typescript type definition file in package.json
  • Chore: Updated dependency @feathersjs/errors@4.5.3 -> 4.5.11
  • Chore: Updated devDependencies: mocha, eslint, eslint-plugin-react, eslint-plugin-jsx-a11y

Package Name Change

Choose a tag to compare

@toddbluhm toddbluhm released this 23 Dec 00:28
acd73b2

4.0.0

  • Breaking: NPM package name changed from @featherjs-plus/validate-joi -> feathers-validate-joi
  • Breaking: Changed core dependency from @hapi/joi -> joi
  • Change: Migrate to nyc from istanbul
  • Change: Migrate to github-actions from travis (future proofing)
  • Change: Added dependabot config (future proofing)
  • Change: Removed yarn lockfile
  • Change: Added .github templates

🎁 More context in errors

Choose a tag to compare

@marshallswain marshallswain released this 22 Jun 21:56

Thanks to a pull request by @mkovel, errors now include valuable debugging information from the hook context:

  • path
  • type (before or after hook)
  • method

TypeScript Definitions!

Choose a tag to compare

@marshallswain marshallswain released this 02 Jun 03:47

Thanks to the work of @digitalcortex, version 3.3.0 of @feathers-plus/validate-joi now includes TypeScript definitions. 🥳

🎁 validateProvidedData Hook

Choose a tag to compare

@marshallswain marshallswain released this 14 Apr 00:15

Introducing the validateProvidedData Hook

The validateProvidedData hook is just like validate.form, but it only validates the attributes from the schema which are actually present in the request's data object. In short, it allows partial validation of the schema attributes. Using it as a hook looks like this:

const validate = require('@featehrs-plus/validate-joi')
const attrs = require('./faqs.model')

const hooks = {
  before: {
    patch: [
      validate.validateProvidedData(attrs, { abortEarly: false })
    ]
  }
}

The above example supposes that you have an /faqs service with a model that looks like the following. Notice how the attrs are defined as a separate object, then they are used in the schema and made available in the export. The validateProvidedData hook uses the individual attrs to validate each individual item in the request's data object.

// src/services/faqs/faqs.model.js
const Joi = require('@hapi/joi')
const { objectId } = require('@feathers-plus/validate-joi-mongodb')

const attrs = {
  _id: objectId(),
  question: Joi.string().disallow(null).required(),
  answer: Joi.string().disallow(null).required(),
  isPublic: Joi.boolean().default(false),
  createdBy: objectId().disallow(null).required()
}

module.exports = {
  attrs,
  schema: Joi.object(attrs)
}

🎁 Validate anything in context

Choose a tag to compare

@marshallswain marshallswain released this 18 Feb 17:46

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)
    ]
  }
}

🎁 FeathersJS v4 support + Big Update

Choose a tag to compare

@marshallswain marshallswain released this 18 Feb 17:48

Lots of updates in this release.

  • 🙌 Updated to work with latest @hapi/joi.
  • 🎁 Support for asynchronous validations.
  • 🚀 Support for FeathersJS V4.
  • 🤷‍♂️ It might still support FeathersJS V3, because the callback syntax is still supported.

Since Joi.validate() has been removed, all validations now use schema.validateAsync(), which means this package now supports asynchronous validations.