Catalog npm
Back to packageRELEASE DETAILS

0.0.18

npm

@0bdx/ainta

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

validatevalidation
Published17 Apr 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-PZI23w7+3HqChMRpO3NKWXlRXH7aKExRYV7sp5rT0ujh8qj13DihVQAH39SKxKSqdQ+56JXO9REjZ3pkghTv7g==",
  "shasum": "26b95b8bf4a64144a11172f7875a2a2475af6794",
  "tarball": "https://registry.npmjs.org/@0bdx/ainta/-/ainta-0.0.18.tgz",
  "fileCount": 6,
  "unpackedSize": 113651,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQDTbKfHWAew0fE47D+sG+VKl7dPXrGQqNIJBZTpqrktugIgTbBJGulgdj6ptXXzVgJCp2ZErbdlaRCS2UnSQxB3am0="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkPURlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqN7xAAgO46Z8Sh5a1PKlyrtnMv3V7I/TB3rnm4PiJ+wdkUaG7K27ak\r\nMKJX7l7B1o+vCe9hfpZQXNGqgJgM3vY1FELbAESqBXs6Y4iijtbx82DFg/FT\r\nI3mcOFFBj0FJw6XlLM4j/wTaM8hCp5zwXm/3bO8kJJYtV5v7bviRk61ZrCbA\r\ngMbWCjc51N9o6qoNolmM7uMvEkx/jj/RA9yfarQxyxNirB4Ido3W8RLXi0Qu\r\nqbOy2OU4snne6rkZXOYUTcWYeMOX1qTFOWonk/OVSFNVCvgxcO3QFwxnoEfU\r\n7VDerz3x9mTyAO9QzB80Ppagqc2o5PmidHO3DK+kfIreE5WkS5RLqq4Tl5tu\r\nyaGUrunyeE78gCeurJ3nP3PihFopZUdMxfbQqV3apuPtpjQ52nvVraq/SSaf\r\nPjMSNPOofybYIdrU0Wj4Zop6/RL7MZc3DTy9MHChix6le9cOT107TSh8VMXQ\r\nkFh5yJGrtFN3W2g1TP+6jRKekFR91uVE9rPa4SzjDEuiYsTAnwc3yolQf51U\r\nAzU9I73xgTOa9HHARsnMBKQXg3YGBQSvYs2/ee1XKi1CnucjEMviaRqIrcwe\r\nVGykh7HLuwPEl81a3HxKeGct6m79IQr6rJlPtxrCWXqQQTZ/gKylDYtzzWfE\r\n/AeByU5V5JaQWqQxmThZYAY1HOt/Zuffolg=\r\n=7fOA\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:b313186fc066a3b8394ddb81ca0de0e4fa256525d6a91f769bb2daf0bf0bca2b

Other collected versions

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