Catalog npm
Back to packageRELEASE DETAILS

0.0.9

npm

@0bdx/ainta

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

validatevalidation
Published2 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-M87i3r6Yy14+2JGnFlp044/b+oGqYv1P8RB5koBjbOCXhZZqkJsTbHqiiSGXRhcMIShomJt+XFOpEZr1Fdnn6g==",
  "shasum": "6b5a8aba24eac50c731ec4b493f58a1fd5e72f99",
  "tarball": "https://registry.npmjs.org/@0bdx/ainta/-/ainta-0.0.9.tgz",
  "fileCount": 6,
  "unpackedSize": 81786,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIQChs5tdkZnrkVvyExgfuD7/oBdxji9wlMv58gG6zDM0GwIgEhRqialMRBOQ4oK0emsPcFuSXvVzL6zfxcx3UZN8Q1A="
    }
  ],
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkKaWtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqnhw/7BhsQTs79lfMFECNAY1f5lkui8Nh1d39RiBJB5pfCKeCo6jtF\r\n4mLIWw+924tbf+I9YD+LLIsgBiQ98AZEEtkWGFOpxL8r05D+FnbkSA0skVht\r\nNGO+Vu/omXC2MBOh30D/0piV2GaDFx+svwT1Gmg9wjOigGG4sFMnf0KI0snI\r\nxLIWlYcZs6VhsSQqZsEbOvV0DxJc50Hy7auQGHO0r4I/g44pQUqiNS6ulBJw\r\nF7m+YmCqFxOE13IpYu5CoqNvrOLirVSqTWG7XORwHR2TKoK4U9CcLtm8DzDn\r\na6iYwa6RvdNE/kSnvDVTTvc+361iovLcxpXiYH3ZJQtjOm92ZCK8+bn+EEjc\r\n5OqEMUCkuiB8jyiemFxsseASLGRII3OraC3lbx0V4NqLO+W90+Elu1SsZ6wc\r\nDk8RIDwr5ZUSAAsgMpHF892HcIZSODOnEhTAmr6AiRuri65Vpz79PUBPdkTE\r\nasPJKPWX3mtjklOoc7jEjR15X686SBFQBkCfcWtLKDLzEnSo5kE2/r8ld/ZE\r\nEojZZIqvMUttKqopGJY9mezS9CsDfjntNeXuYLyoYS+N3NmLZAo3Q9ykBrsQ\r\naBfqt3VHIJAxZvWzZmLrRieYCq3gvLr4GdRadIUocbY1hwZgslK03PDv4Dkw\r\nboCWxxZ9QgYr7UwwlvZAqiNozSHY5+JItd0=\r\n=gkeI\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:ff2fc0279cdf6c5beff5511fe22ada3f28aa1180f5fbc52d85e1a364dc86454d

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 →