Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rafaelgss/var-validate
Just validate some things. :star:
https://github.com/rafaelgss/var-validate
Last synced: about 1 month ago
JSON representation
Just validate some things. :star:
- Host: GitHub
- URL: https://github.com/rafaelgss/var-validate
- Owner: RafaelGSS
- License: mit
- Created: 2019-10-28T20:04:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T07:29:28.000Z (almost 2 years ago)
- Last Synced: 2024-10-06T01:56:25.753Z (about 2 months ago)
- Language: JavaScript
- Size: 79.1 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# var-validate
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
[![Actions Status](https://github.com/RafaelGSS/var-validate/.github/workflows/action.yml/badge.svg)](https://github.com/RafaelGSS/var-validate/actions)Just validate some things. :star:
## Install
```sh
npm i --save var-validate
```## Tests
```sh
npm install
npm test
```## Usage
```js
const validate = require('var-validate')const inputValid = 'CAR'
validate(inputValid, 'DEFAULT') // CARconst inputInvalid = undefined
validate(inputInvalid, 'DEFAULT') // DEFAULTconst inputEnum = 'BIKE'
validate(inputEnum, 'DEFAULT') // BIKE
validate(inputEnum, 'DEFAULT', { includes: ['CAR', 'AUTO'] }) // DEFAULT
validate(inputEnum, 'DEFAULT', { includes: ['CAR', 'AUTO', 'BIKE'] }) // BIKEconst inputExcept = 'CAR'
validate(inputExcept, 'DEFAULT', { except: ['BIKE'] }) // CAR
validate(inputExcept, 'DEFAULT', { except: ['BIKE', 'CAR'] }) // DEFAULT
```## License
MIT