1.0.0 • Published 1 year ago

@micromint1npm/occaecati-at-incidunt v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@micromint1npm/occaecati-at-incidunt · GitHub license npm Package Status Test Status

Type checking utils.

Installation

npm install @micromint1npm/occaecati-at-incidunt --save

Usage

const t = require('@micromint1npm/occaecati-at-incidunt')

const objConstraint = t.object.is({
  num: t.number.gte(0).required,
  str: t.string.match(/\d+/).required
}).required

const result = objConstraint.validate({ num: 1, str: '1' })
// result = { valid: true, errors: [] }

const result = objConstraint.validate({ num: 0, str: '1' })
// result = {
//  valid: false,
//  errors: [{ name: 'num', expected: 'gte(0)', actual: 0 }]
// }

Built-in constraints

  • bool
    • bool.required
    • bool.truthy
    • bool.falsy
  • number
    • number.required
    • number.eq(<number>)
    • number.neq(<number>)
    • number.gt(<number>)
    • number.gte(<number>)
    • number.lt(<number>)
    • number.lte(<number>)
  • decimal
    • decimal.required
    • decimal.eq(<number|string>)
    • decimal.neq(<number|string>)
    • decimal.gt(<number|string>)
    • decimal.gte(<number|string>)
    • decimal.lt(<number|string>)
    • decimal.lte(<number|string>)
  • string
    • string.required
    • string.lenEq(<number>)
    • string.empty
    • string.notEmpty
    • string.match(<regexp>)
  • time
    • time.required
    • time.eq(<number|string|Date>)
    • time.neq(<number|string|Date>)
    • time.gt(<number|string|Date>)
    • time.gte(<number|string|Date>)
    • time.lt(<number|string|Date>)
    • time.lte(<number|string|Date>)
  • array
    • array.required
    • array.lenEq(<number>)
    • array.empty
    • array.notEmpty
    • array.of(<itemConstraint>)
    • array.is([<itemConstraint>, ...])
  • object
    • object.required
    • object.eq(<object>)
    • object.match(<object>)
    • object.is({ key: <constraint>, ... })
    • object.like({ key: <constraint>, ... })
  • nil
  • eq(<any>)
    • eq(<any>).required
  • neq(<any>)
    • neq(<any>).required
  • oneOf([<any>, ...])
    • oneOf([<any>, ...]).required
  • valueOf({ key: <any>, ... })
    • valueOf({ key: <any>, ... }).required
  • use
    • use(({ parent, value }) => constraint).required

License

MIT

negative zeroECMAScript 5globstreams2rm -rfcssWeakMap256util.inspectl10ntimeagentbyterfc4122Symbol.toStringTagObservableenderinvariantnpmsafeArray.prototype.filterroute53spinnersindicatormruespreeECMAScript 2018createcopypackagesprivategenericsoptionmodulesInt32ArraythroatmochaECMAScript 2017Object.assigndescriptorsprogressmovei18npasswordObject.isclass-validatorsetgradients csses7queueassertionargsequalregular expressionstraverseforEachfluxconfigcollection.es6clonecss-in-jsfile systemdependency managerphonemulti-packageworkspace:*bundlinglessargumentES8oncereplaypluginiteratesortedpromisesjavascriptformPromisecore-jscallbackObjecttapArray.prototype.flatoutputcachebrowserliststarterhookformECMAScript 2020authenticationSymbolvisualmkdirpconsoleprivate dataCSSprotoelectronswfaccessibilitysesdeleteformsCSSStyleDeclarationentrieslockfilekeysarraysYAMLfunctionalhasOwnPropertyshebangemrvestFloat32Arraybuffergraphqles2016symlinksfunctionsMicrosoftconcurrencyhelpersless compilerES2021uninstallpipeasyncchineseWebSocketsarraybufferextendSetquotemergeESlinewrapcoreasciiboundRFC-6455redux-toolkitcloudfrontworkflowflatMapexpressopenfunctioncurldatastructureESnextttyjsiamURLjestparsetypedarrayskinesisRxInt16Arraycss lesses-shim APIfast-copyUint8Arrayes6ES2016reducewhatwgsymbolsvaluesregextesternamesbannerhasguidtestObject.keyscloudsearchkoreanhashArrayBuffer.prototype.slicejapanese$.extendinternal slotio-tslesscsstelephonecontainsresolvecolourfilepredictablewordwrapchannelapiformat[[Prototype]]mobileECMAScript 2023sideprotocol-buffersES2022everyfixed-widthemitjsdiffsuperstructstringserializationjasmineduplexsettingsstatedotenvlanguageworkerURLSearchParamstasklazyslotArrayBufferavatrimRightpostcss-pluginremovewatchingemojityped arrayFloat64Arrayelbcall-bindlengthES2023pathrecursivejQueryimmerlooknumberpatchnamestatelesseventDispatcherfull-widthwidtheast-asian-widthdynamodbregular expressionprettyfastcopysyntaxtypeofStyleSheettrimEndfseventsdomxhrcallboundtostringtagsuperagentarrayfpsES3toolselmoptimizerECMAScript 2019StreamArray.prototype.containsoptimistpropertiestypeerrorsetterproxydirectoryshimBigInt64ArraytstermdirtrimStartwritepnpm9propmoduleqsinputrandomchromiumtoArraywritableredactspecperformantenvreact-hook-formconsumeES2017jsxansi
1.0.0

1 year ago