• Stars
    star
    607
  • Rank 71,499 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“ A library for data validation.

Build Status Coverage Status Code Climate

A library for data validation.

Install

ValidateJS is available on npm:

npm install valid.js --save

or bower:

bower install valid.js

Usage

With ES6/import

import {validate, string, util, isValid} from 'valid.js'

let testIsValid = validate(string.maxLength(15), util.isRequired)
let result = testIsValid('Test ValidateJS')
// result => true

// or using the 'isValid' shorthand method
let result = isValid('Test ValidateJS', [string.maxLength(15), util.isRequired])
// result => true

With require

var validatejs = require('valid.js')
var validate = validatejs.validate,
    isValid = validatejs.isValid,
    string = validatejs.string,
    util = validatejs.util

var testIsValid = validate(string.maxLength(15), util.isRequired)
var result = testIsValid('Test ValidateJS')
// result => true

// or using the 'isValid' shorthand method
var result = isValid('Test ValidateJS', [string.maxLength(15), util.isRequired])
// result => true

With Browser

<script src="./bower_components/valid.js/dist/validate.js"></script>
var validate = validate.validate
var string = validate.string
var util = validate.util

var testIsValid = validate(string.maxLength(15), util.isRequired)
var result = testIsValid('Test ValidateJS')
// result => true

OR

var validate = window.validate.validate
var string = window.validate.string
var util = window.validate.util

var testIsValid = validate(string.maxLength(15), util.isRequired)
var result = testIsValid('Test ValidateJS')
// result => true

OR

var isValid = window.validate.isValid
var string = window.validate.string
var util = window.validate.util

var result = isValid('Test ValidateJS', [string.maxLength(15), util.isRequired])
// result => true

Also available for AMD

Validation Functions

  • String
    • isString
    • minLength(min)
    • maxLength(max)
    • length(min, max)
    • regex(reg)
  • Number
    • isNumber
    • minNumber
    • maxNumber
    • between
  • Date
    • isDate
    • minDate(min)
    • maxDate(max)
    • between(min, max)
  • Bool
    • isTrue
    • isFalse
  • Util
    • isRequired
    • isEmail
    • isCep
    • isUrl
    • isHexColor
    • isCpf
    • isCnpj
  • Credit Card
    • isVisa
    • isElo
    • isHipercard
    • isMasterCard
    • isDiners
    • isAmex
    • isCreditCard

Contributing

Send us a Pull Request! Here is how:

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Stage your changes: git add .
  4. Commit your changes: git commit -m 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request

LICENSE

The MIT License (MIT)

Copyright (c) 2015 Daniel Leite de Oliveira

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

strman

๐Ÿ—A Javascript string manipulation library.
JavaScript
2,010
star
2

react-fetches

๐Ÿ™React Fetches a new way to make requests into your REST API's.
JavaScript
249
star
3

walletjs

๐Ÿ’ณA little library to handle money amounts.
JavaScript
187
star
4

crates

๐ŸŒŽ A tool to generate your locale files compatible with i18n.
JavaScript
52
star
5

fetches

๐Ÿฆ‘Fetches is a workaround to make requests, in an easy and scalable way.
JavaScript
16
star
6

twitty

A simple but gold Twitter Command Line Client.
JavaScript
14
star
7

ng-clipboard

AngularJS directive to copy or cut text to clipboard without using flash.
JavaScript
10
star
8

gulp-es6

Using gulp with es6
JavaScript
6
star
9

showdeps

A little library to list all imports in a code.
JavaScript
5
star
10

babel-plugin-transform-remove-import

This plugin removes all import calls.
JavaScript
5
star
11

react-cep

Componente em React para acessar api de cep
JavaScript
5
star
12

service-worker-sandbox

My Service Worker Sandbox
JavaScript
3
star
13

babel-plugin-transform-remove-export

This plugin removes all export calls.
JavaScript
2
star
14

api-twitter-example

Testes na plataforma Twitter
JavaScript
2
star
15

formating

A simple library for data format
JavaScript
2
star
16

dleitee.github.io

Meu site pessoal
CSS
1
star
17

design-patterns-features

1
star
18

tic-tac-toe-server

1
star
19

dotfiles

My dotfiles
Shell
1
star
20

todo-api

JavaScript
1
star
21

gulp-basic

Basic Gulpfile
JavaScript
1
star
22

config-default

My default config
JavaScript
1
star
23

gulp-with-modules

How to use gulp with modules
JavaScript
1
star
24

meusalgado

รrea de orรงamento do site Meu Salgado
JavaScript
1
star