Catalog npm
PACKAGE EXPLORERView in registry

@0bdx/ainta

npm

Utilities for validating values in apps, libraries and websites.

validatevalidation
Versions collected20
Direct dependencies3From release 0.0.20
Last observed20 Oct, 22:04 UTC

README

Current package documentation

@0bdx/ainta

Utilities for validating values in apps, libraries and websites.

∅  Version: 0.0.20
∅  NPM: https://www.npmjs.com/package/@0bdx/ainta
∅  Repo: https://github.com/0bdx/ainta
∅  Homepage: https://0bdx.com/ainta

@TODO add an overview

Examples

Basic usage:

import { aintaBoolean } from '@0bdx/ainta';

aintaBoolean(true);
// false

aintaBoolean(1234);
// "A value is type 'number' not 'boolean'"

aintaBoolean(null, 'isDone', { begin:'doThings()' });
// "doThings(): `isDone` is null not type 'boolean'"

Using the narrowAintas() helper:

In the example below, narrowAintas() is used to narrow aintaNumber() into aintaNatural(), and then capture its validation results:

  • begin:'bothNatural()' sets a prefix, added to all explanations
  • gte:0 checks that the value is not negative
  • mod:1 checks that the value is an integer
  • lte:1000 and lte:50 specify different maximum values for each argument
  • if (results.length) checks whether there were any problems
import narrowAintas, { aintaNumber } from '@0bdx/ainta';

function bothNatural(a, b) {
    const [ results, aintaNatural ] = narrowAintas(
        { begin:'bothNatural()', gte:0, mod:1 },
        aintaNumber
    );
    aintaNatural(a, 'a', { lte:1000 });
    aintaNatural(b, 'b', { lte:50 });
    if (results.length) return results;
    return "a and b are both natural numbers, in range!";
}

bothNatural(-5, 12.34);
// [ "bothNatural(): `a` -5 is not gte 0",
//   "bothNatural(): `b` 23.45 is not divisible by 1" ]

bothNatural(99, 200);
// [ "bothNatural(): `b` 200 is not lte 50" ]

bothNatural(12, 3);
// "a and b are both natural numbers, in range!"

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 20

Collected releases
VersionPublishedDirect dependenciesOpen version
0.0.20Registry latest6 Oct 20233
0.0.194 May 20233
0.0.1817 Apr 20233
0.0.1716 Apr 20233
0.0.1613 Apr 20233
0.0.157 Apr 20233
0.0.146 Apr 20233
0.0.134 Apr 20233
0.0.124 Apr 20233
0.0.114 Apr 20233
0.0.103 Apr 20233
0.0.92 Apr 20233
0.0.829 Mar 20233
0.0.725 Mar 20233
0.0.623 Mar 20233
0.0.523 Mar 20233
0.0.422 Mar 20234
0.0.321 Mar 20233
0.0.218 Mar 20233
0.0.15 Mar 20233

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
0bdx/ainta

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:04 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:8a5bd0b1b92412f125a90981a56ad46920e8d82a046de84ebb4c212fe4ce3e14