@alidatorjs/is-greater-than
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

is-greater-than

Tiny function, compatible with Alidator.js, to validate if a value is greater than other.

Install

You can use npm or yarn to install it.

$ npm install --save @alidatorjs/is-greater-than

$ yarn add @alidatorjs/is-greater-than

Then with a module bundler like rollup or webpack, use as you would anything else:

// using ES6 modules
import { isGreaterThan } from '@alidatorjs/is-greater-than'

// using CommonJS modules
var { isGreaterThan } = require('@alidatorjs/is-greater-than')

Usage

Is as easy as define an array with the validations.

import { validator } from '@alidatorjs/validator';
import { isGreaterThan } from '@alidatorjs/is-greater-than';

const isValid = validator([
    isGreaterThan(1, 0),
    isGreaterThan(2, 1),
    isGreaterThan(3, 2),
]).every; // true

const errors = validator([
    [isGreaterThan(1, 0), () => 'Error 1'],
    [isGreaterThan(1, 2), () => 'Error 2'],
    [isGreaterThan(3, 2), () => 'Error 3'],
]).errors; // ['Error 2']

License

MIT License

Dependents (0)

Package Sidebar

Install

npm i @alidatorjs/is-greater-than

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.89 kB

Total Files

12

Last publish

Collaborators

  • gc-victor