@cweise/redux-valacts
v0.1.0
Published
Create redux actions and validate their payload. Can be used next to redux-actions library.
Downloads
4
Readme
@cweise/redux-valacts
redux-valacts is a small companion library to create flux like redux-actions with a validation schema.
Install
npm i @cweise/redux-valacts yup --save
yarn add @cweise/redux-valacts yup
Usage
import { object, string } from "yup";
import { createAction } from "@cweise/redux-valacts";
const validationSchema = object({
username: string().required(),
password: string()
});
const login = createAction("LOGIN", { validationSchema });
// This will throw an error because username is required
login({
username: "",
password: "XXX"
});