Catalog npm
Back to packageRELEASE DETAILS

0.0.7

npm

@0bdx/ainta

Utilities for validating values in 0bdx apps, libraries and websites.

validatevalidation
Published25 Mar 2023
Direct dependencies3
Transitive dependenciesNot calculated

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.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@0bdx/build-helpers
Environment
{
  "local_name": "@0bdx/build-helpers",
  "alias": false,
  "peer_metadata": null
}
^0.0.4development
@rollup/plugin-terser
Environment
{
  "local_name": "@rollup/plugin-terser",
  "alias": false,
  "peer_metadata": null
}
^0.4.0development
rollup
Environment
{
  "local_name": "rollup",
  "alias": false,
  "peer_metadata": null
}
^3.18.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-5SFgPsxF6CaNj4jVNZHmTOnIGF4jL4nJccUstVFL9id6YjCz+Z6OpGgvmhFp0rU7T0u5hMsrt4pmlpLNLKOA6g==",
  "shasum": "6cecc079e0fd7d6ee5a52945d5a0ae8fd38443f5",
  "tarball": "https://registry.npmjs.org/@0bdx/ainta/-/ainta-0.0.7.tgz",
  "fileCount": 6,
  "unpackedSize": 79178,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQDI44y3wQKjn1DaSpcN8cGiZHGH574KWKWfNxR4+nMbxwIgJdcuvnyOtyHEEIJ4qE6XgMTo7SbBlJAND1rzCLUrKto="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkH3OgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpy7g/+PsTe9tOKFu4oXzjPmHS4rv/uxpgtHdHYdOfhaJ1MHIdoLi2a\r\nW2FrPhzJdR2AaSYmTj588ET0dZ5c8QWxn6O3Roeb4k2vh4ukrmHWX6950LUC\r\n2HF58uPZTmn76XHhOP3NcYZE5aWFqqUPTgVUfZX5TPf6f3r35T8XCRH/hfW6\r\nmYQRmR6GJYq8PPIn2BV/OIlog6nxLwTJ7yCE9uuFVHpztj6ozLoQnXX3KdSY\r\nU6mqPPC0LOJIfQPLGXnE1OvRogcOyfB0cDkyK5s8QJ6yAomIlksFhFlxEOM4\r\nsqA79DAbFRU5yOHz5bXngaQ7c5I5JV1ILXeZVxOx1ALtdEq5thd9GAmhLJQr\r\nn8AsuaMpaOGhaDYhSeYo/doyZCnjrQvTX2E3gu8DLWve1DLz2UzvAQz4ZB9V\r\nyB9XuaMinBnZMKMY1hw8bsJ/ATge/1SrtXhCHYPHFrjSd+LFjWMfLNhtrPzy\r\nBuiJgbfCraj5gOVFl5appFsN3d+PI+BNAPL/9iq/V7H/n/Ugs3Ucm/H3a3BS\r\nxfNear0ipFNCWbZ0kZAENqGA0bwwVPowic1djeH7wfZY78m3A9gh1RxE7t6/\r\nTyFYvsin5Sd0QlAbDU0B8w1Dpn5Kx7NePegOKWUq1WiYgSN9i1oyZSgQw1MO\r\nY2720R4HkgQSfF47oInIbZ8SgXnqSnnfvnI=\r\n=EKw+\r\n-----END PGP SIGNATURE-----\r\n"
}

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_version:7ae6ebd3326b6299662c959dfc3ffd50ca569810cb8fd94f2ac52d7db4cd3831

Other collected versions

0.0.206 Oct0.0.194 May0.0.1817 Apr0.0.1716 Apr0.0.1613 Apr0.0.157 AprView all collected versions →