Catalog npm
Back to packageRELEASE DETAILS

0.0.8

npm

@0bdx/ainta

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

validatevalidation
Published29 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-bNQgfXXPqK3QV6fJ+OS8xTXlr8GV/bnNCsiufwv5RqSs6c6F1uwkdRn3J8Pmhr/wSoJS9+Ao+NEMjt76nHd4Jg==",
  "shasum": "d7f26433c0d356a1bc1b5423acbec7ab3b2707b1",
  "tarball": "https://registry.npmjs.org/@0bdx/ainta/-/ainta-0.0.8.tgz",
  "fileCount": 6,
  "unpackedSize": 81369,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQCUiW21GB2sTsaM0Bma978EH1hSRilE0ekRg8oirdpIqgIgN7Gw24eq+XYr2R0GfLLsrjy2F/sUcICKvkzBIkFaYEk="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkJE47ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr9ThAAkW9wGWxpA+09Aq6q7yD/0dxHzI1OZmFEbxIeykFDcqqewmkf\r\nbQ5wQRPZ5zBnhUTevpZY7i988aI4Aeyhgv014JXP0nZxmWGEdT3H+QVHJNMZ\r\nOVC3mM9uS3yXKG/uCu6QO9r9DjDDx9iOXtuGKoGWmANokFYP+jpMQmiTVJ1v\r\nwdfin6gGSbfQ6yv2IpZpfKb3fuLnD1AdTbmge8tPO7hrJLGiHqpbBUHtC9e0\r\nksheTUClr7fvgc2HNkDtMuY4aTfltxmFwuoyuZsWsES+DVZOnVk/qkyoPXax\r\naCD0Mc8FwtAtUweCkqgpjiE3szCTHyPf6NtZXe7Pp6PY3MQV70Qa3jvhx2/z\r\nNvJvEuQPtOjN1hsnh0lDKYNcy52lnvGHy5hWqrbuFhrSSL5/j284ZthroHo5\r\nxIaKSiw2jPijQFCs5UVVXImBvvwVcEdeIoDLPgFoUUydqDhNDulHvlMNjQjx\r\nOVn2dUf0CRFeOnWSF7HA1F5+beEa1juTn9WzcEWjYNfi0cC3apBXB7og35Oz\r\ncMf/WJJBF2X8ZxBniy8frzW+cUNXJBGUlaW/1wHbsTPRmG39utYwwkgM4n+A\r\nA7L8yNmnPT2nsoBlb+HOUQexxsb11Q/K+tLs2bjcucUm1PFnK2BzFbTng53A\r\npSMHeHaRZ+8bwclo8E8eeVmwSgWpbVS5gOs=\r\n=wkia\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:c50b4e61fb7aa7dbf948549fb836f980bc2cbed5ef623f7a1ce83abbe2f9337e

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 →