1.9.0 • Published 7 years ago

quick-validator v1.9.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

QuickValidator

Easy way to validate any form data

Installation

	<script src="quick-validator.js"></script>

or

    npm install quick-validator --save

basic usage

	const QuickValidator = require('quick-validator')

or

	import QuickValidator form 'quick-validator';
	const form_data = {
		name: 'Najrul',
		digit: 10,
		number: '123', // 123 - true
		integer: 123, // '123' - false
		username: 'najrul_ahmed',
		email: 'example@gmail.com',
		image: new File([''],'filename.jpg') // or [f1,f2]
	}

	const validate = QuickValidator (form_data,{
		name: 'required|min:10|max:20',
		digit: 'digit:5',
		number: 'number', // true
		integer: 'integer', // true
		username: 'required|username',
		email: 'email',
		image: 'required|min:2|max:4|file|extention:jpg,png'
	})

	if(validate.passed()){
		// success
	}else{
		// error
		console.log(validate.errors)
	}
	
	validate.first() // first error item
	validate.allfirstErrors() // [] get all first error with array
	validate.hasError('name') // true/false
	validate.allErrors() // [] return all errro with array
	validate.each((item, name) => {
		console.log(item)
	})

Validation Rules

  • required
  • min:1
  • max:9
  • file
  • filesize: min-1234123, max-234234
  • extention: jpg,png
  • mimetype: image/jpeg, text/plain
  • string
  • digit:10
  • integer
  • number
  • array
  • object
  • equal: another field name
  • email
  • username
  • url
  • ip
  • date
  • cc (credit-card)
1.9.0

7 years ago

1.8.0

7 years ago

1.7.0

7 years ago

1.6.0

7 years ago

1.5.9

7 years ago

1.5.8

7 years ago

1.5.7

7 years ago

1.5.6

7 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago