0.3.2 • Published 5 years ago

@viewitjs/validate v0.3.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Build Status Test Coverage Maintainability

ViewitJS Validate

Viewit JS Validate Module

Getting Started

Please install the package

npm i @viewitjs/validate

How to use it

const Validator = require('@viewitjs/validate')
const validate = new Validator()

Methods

typeOf

Set the type and value

validate.typeOf('string', 'text')
validate.typeOf('number', 2)

const text;
validate.typeOf('undefined', text)

validate.typeOf('null', null)

validate.typeOf('array', [])
validate.typeOf('object', {})
validate.typeOf('function', () => {})
validate.typeOf('symbol', Symbol())

This method return true if the type match with the value

isEmpty

Set value

const value = ''
validate.isEmpty(value)

This method return true if the value is empty

bySchema

Set the schema and data

const schema = {
	id: 'number',
	body: {
		content: 'string'
	}
}

const data = {
	id: 2,
	body: {
		content: 'Hello World!'
	}
}

validate.bySchema(schema, data)

This method return true if the data againts the schema

  • If some property not found or not match with type provided return false

getErrors

Get the array of validation errors

validate.getErrors()

Prerequisites

Before installing, download and install Node.js

V8 or higher is required.

Development

If you want to parcipate please visit viewitjs

Navigate to a project folder where you want to work and fork the repository

git fork git@github.com:viewitjs/validate.git {package name}

Install all dev dependencies

npm install -D

Create new branch and start work & enjoy it

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We are in firsts stages of the development. If you want to contribute with this project please visit:

ViewitJS

Authors

  • Diego Londoño - Viewit Team
  • Elias Valdez - Viewit Team

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • To all interested contributors
0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago