Skip to content

FelixRiddle/checkpoint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Checkpoint

Data validation package and other miscellaneous things.

Introduction

Last update: 2.0.0 This is an introduction to checkpoint

Create a validator

import Validator from "validator";

// Create a validator and multiple scopes
let val = new Validator()
    .createScope("email", "email", "[email protected]")
    .isNotFalsy()
    .isEmail()
    .lengthRange(5, 64)
    .isStr()
    // Use scope
    .useScope("email", "friend_email", "[email protected]")
    // Create new scope
    // These ones pass
    .createScope("username", "username", "my_cool_username_65")
    .isNotFalsy()
    .lengthRange(5, 64)
    .isStr()
    // Phone scope
    .createScope("phone", "phone_number", 6756829123)
    .isNotFalsy()
    .isNum()
    // Use phone scope again
    // And fail both tests
    .useScope("phone", "alt_phone", "");

Perform validation and check if passed

// Perform validations
let result = val.validate();

// The result should have an array of 'ValidationResult' objects
if(result.length > 0) {
    console.log(`Not all validations passed`);
}

Print every result message

// Perform validations
let result = val.validate();

// Print result messages
for(let res in result) {
    console.log(`Field: ${}`, res.field);
    console.log(`Message: ${}\n`, res.message);
}

Todo

  • Form fetch all parses what is clearly a number or float
  • Data validation
  • Object validation
  • Scopes

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published