2.0.5 • Published 1 year ago

felixriddle.checkpoint v2.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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", "felix@email.com")
    .isNotFalsy()
    .isEmail()
    .lengthRange(5, 64)
    .isStr()
    // Use scope
    .useScope("email", "friend_email", "joe@email.com")
    // 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
2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago