Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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:

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') // CAR

const inputInvalid = undefined
validate(inputInvalid, 'DEFAULT') // DEFAULT

const inputEnum = 'BIKE'
validate(inputEnum, 'DEFAULT') // BIKE
validate(inputEnum, 'DEFAULT', { includes: ['CAR', 'AUTO'] }) // DEFAULT
validate(inputEnum, 'DEFAULT', { includes: ['CAR', 'AUTO', 'BIKE'] }) // BIKE

const inputExcept = 'CAR'
validate(inputExcept, 'DEFAULT', { except: ['BIKE'] }) // CAR
validate(inputExcept, 'DEFAULT', { except: ['BIKE', 'CAR'] }) // DEFAULT
```

## License

MIT