https://github.com/margato/fva
A module to validate your data.
https://github.com/margato/fva
form form-validation form-validator
Last synced: 2 months ago
JSON representation
A module to validate your data.
- Host: GitHub
- URL: https://github.com/margato/fva
- Owner: margato
- Created: 2019-03-10T07:17:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-17T18:38:05.000Z (almost 7 years ago)
- Last Synced: 2026-03-16T13:59:00.347Z (3 months ago)
- Topics: form, form-validation, form-validator
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/fva
- Size: 18.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fva - Form VAlidator
A module to validate your data.
# Installation
In order to use this module, run
```bash
$ npm install fva
```
# Usage
```javascript
const fva = require("fva")
const data = require("../data.json")
const jsonRules = {
title: { required: true },
description: { required: false },
author: { required: true },
authorEmail: { email: true },
authorAge: { number: true }
}
const customErrorMessages = {
title: { required: "This is a required field" },
description: { required: "This is a required field" },
author: { required: "This is a required field" },
authorEmail: { email: "This is an email field" },
authorAge: { number: "This is a number field" }
}
//The third parameter is not required
fva.validate(data, jsonRules, customErrorMessages)
.then(res => {
//Do something...
})
.catch(err => {
//Handle error...
})
```
# Preview
See a live preview [here](https://repl.it/@Margato/fvaExample).