a(ny)yup. Useful Yup helpers and functions. Synchronous and Async.
Add via Yarn
yarn add @aibex/ayup
or via npm
npm install @aibex/ayup
ayup is designed to be a simple way to do hard things in yup. Yup's lightweight, asynchronous, and generally a better choice for simple validation. But some edges are rough. And if you're here, you're probably rubbing against one of those right now.
For every method, both synchronous and asynchronous support is available. By default, every plugin is ready to be added to yup via
yup.addMethod. However, if polluting the global yup object isn't your thing, there's an
augment method that favors yup's "template schema" approach. Examples are provided for both routes.
Create a template object, containing non-global versions of one or more ayup plugins. Augment walks through the list of supplied plugins, associates them with the plugin's yup
type, and returns an object literal containing your schema-ready yup objects.
;;const myTemplateSchemas = ;const mySchema = yupobjectshapemyKey: myTemplateSchemas;
Passes validation if at least one schema in the array is valid.
;;// globally add to yupyup;yupaddMethod; // non-spread operatorconst mySchema = yupobjectshapemyKey: yup;
;;const schemas = ;const mySchema = yupobjectshapemyKey: schemas;
Test are written using
ava. You can run the test suite using
While we use yarn for everything internally,
release-it works more consistently with
npm run-script release. This is because of how npm/yarn manage their logins.