Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cweise/redux-valacts
Create redux actions and validate their payload. Can be used next to redux-actions library.
https://github.com/cweise/redux-valacts
Last synced: 1 day ago
JSON representation
Create redux actions and validate their payload. Can be used next to redux-actions library.
- Host: GitHub
- URL: https://github.com/cweise/redux-valacts
- Owner: cweise
- Created: 2019-12-06T14:43:20.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T02:27:37.000Z (almost 2 years ago)
- Last Synced: 2024-09-22T01:12:14.907Z (about 2 months ago)
- Language: JavaScript
- Size: 825 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @cweise/redux-valacts
redux-valacts is a small companion library to create flux like redux-actions with a validation schema.
## Install
```bash
npm i @cweise/redux-valacts yup --save
``````bash
yarn add @cweise/redux-valacts yup
```## Usage
```javascript
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"
});
```