Versatile Data Validation JavaScript Library

Category: Form , Javascript | July 24, 2021
Author:NouvelleTechno
Views Total:185 views
Official Page:Go to website
Last Update:July 24, 2021
License:MIT

Preview:

Versatile Data Validation JavaScript Library

Description:

A versatile data validation library that provides a set of validation helps for validating field values in an easy way.

Validation Helpers Included:

  • Color
  • Date & Time
  • EAN13 Number
  • Email
  • International Bank Account Number
  • International Standard Book Number
  • JSON Web Token
  • Password Strength
  • Min/Max Values
  • SIREN Number
  • SIRET Number
  • Text Length
  • URL

How to use it:

1. Add validation helpers to your page.

<script src="dist/Color.min.js"></script>
<script src="dist/DateTime.min.js"></script>
<script src="dist/Ean13.min.js"></script>
<script src="dist/Email.min.js"></script>
<script src="dist/Iban.min.js"></script>
<script src="dist/Isbn.min.js"></script>
<script src="dist/Jwt.min.js"></script>
<script src="dist/Password.min.js"></script>
<script src="dist/Range.min.js"></script>
<script src="dist/Siren.min.js"></script>
<script src="dist/Siret.min.js"></script>
<script src="dist/Text.min.js"></script>
<script src="dist/Url.min.js"></script>

2. Check if a color (name, hex, rgb, rgba) is valid. Returns true if valid.

let myColor = new Color();
myColor.isValid("black");
myColor.isValid("#ff0000");
myColor.isValid("rgba(255, 255, 255, 0.4)");

3. Check if a date is valid. Returns true if valid.

let myDate = new DateTime();
myDate.isValid("2021-07-24 14:30");

4. Check if is a valid EAN13 number. Returns true if valid.

let myEan = new Ean13();
myEan.isValid("7612345678900");

5. Check if an email address is valid. Returns true if valid.

let myEmail = new Email();
myEmail.isValid("[email protected]");

6. Check if is a valid International Bank Account Number. Returns true if valid.

let myIban = new Iban();
myIban.isValid("GB98 MIDL 0700 9312 3456 78");

7. Check if is a valid International Standard Book Number. Returns true if valid.

let myIsbn = new Isbn();
myIsbn.isValid("978-2-02-130452-7");

8. Check if is a JWT (JSON Web Token). Returns true if valid.

let myToken = new Jwt();
result7 = myToken.isValid("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");

9. Check if a password string matches the strength level. Returns true if valid.

let myPass = new Password({
    uppercase: true,
    lowercase: true,
    numeric: true,
    special: true,
    minLength: 12
});
myPass.isValid("[email protected]!");

10. Check if a number is between 0 to 100. Returns true if valid.

let myRange = new Range(0, 100);
const result9 = myRange.isValid(99);

11. Check if is a valid SIREN Number (French companies identifier). Returns true if valid.

let mySiren = new Siren();
mySiren.isValid("123 456 789");

12. Check if is a valid SIRET Number (French companies identifier). Returns true if valid.

let mySiren = new Siren();
mySiren.isValid("123 456 789");

13. Check if text length is between 0 to 100. Returns true if valid.

let myText = new Text(0, 100);
myText.isValid("CSSScript.com!");

14. Check if is a valid URL. Returns true if valid.

let myUrl = new Url(["https", "http"]);
myUrl.isValid("https://cssscript.com");

You Might Be Interested In:


Leave a Reply