This package has been deprecated

Author message:

Valur has been renamed to Valuer. Consider installing '@valuer/main' instead

valur
TypeScript icon, indicating that this package has built-in type declarations

0.10.2 • Public • Published

Valur(@npm) is an advanced declarative value validator.


Installation:

$ npm install valur --save

Usage:

(see #18)

To validate a value before its use, just preform validation a couple of lines before.

const root = (radicand: number, degree: number): number =>
    radicand ** degree ** -1;
 
root(8, 3);
// 2 (no error)
 
root(-8, 3);
// NaN (no error, but should be)
 
// ***
 
const rootValidated = (radicand: number, degree: number): number => {
    // roots of negative numbers do not make sense in JavaScript
    // therefore radicand cannot be negative
    valur(radicand, "radicand").as({ spectrum: "non-negative" });
 
    return root(radicand, degree);
};
 
rootValidated(-8, 3);
// Error: Validation failed: radicand is a negative number: value <number> -8, validator "spectrum"

Readme

Keywords

none

Package Sidebar

Install

npm i valur

Weekly Downloads

21

Version

0.10.2

License

MIT

Unpacked Size

27.8 kB

Total Files

7

Last publish

Collaborators

  • parzhitsky