1.0.0 • Published 1 year ago

@crabas0npm2/quis-possimus-harum v1.0.0

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

@crabas0npm2/quis-possimus-harum · GitHub license npm Package Status Test Status

Type checking utils.

Installation

npm install @crabas0npm2/quis-possimus-harum --save

Usage

const t = require('@crabas0npm2/quis-possimus-harum')

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

entriesexitreal-timethroatstylequerystringstreams2descriptorcoercibleurlterminalcheckfunctionpromisesredactECMAScript 2016somejsdiffFloat64ArraymodulesdataHyBieverydataviewhigher-ordercss-in-jshotfastcopysimpledbreactsafevalueStreamsstructuredClonereduceURLmimetypestoArraybindspeedaccessibilitynopecommand-lineString.prototype.trimoperating-systemtestRxJSajaxform-validationglobqueueMicrotaskbyteOffsetUint32ArraygettercolumnstypeerroreventEmittertermTypeBoxsyntaxtoobjectviewfluxshamintrinsiccollection.es6frameworkschemapersistentbddsignalspluginReflect.getPrototypeOfdotenvdeepcopyyamlstylingmimeshebangbatchlengthbrowserbeanstalktsoutputarraysgetPrototypeOftoolskeysmonorepoparentsbootstrap csspropertyargumentprotobufpostcssfixed-widthredux-toolkitvariablesbootstrap lesswaitchaimime-dbavanodeESES2020serializercurlarthasOwnCSSStyleDeclarationReactiveExtensionseventsArrayBufferES6pruneMicrosoftmakedefinetrimEndcharactersutilitiesmkdirscommandgradients css3uuidwatchingdebuggertap$.extendES7lessESnextautoprefixertypescriptES5shrinkwrapvalidreact-testing-librarytestingec2iamObjectnegative_.extendutilbrowserlistxhrargvrobustisConcatSpreadablefullECMAScript 2019find-upoffsetbundlingObservablecallbindstatelessfunctionalWeakMapECMAScript 2018Uint8ClampedArrayconfigfile systemObject.definePropertyfindLastIndexreact-hook-formgroupBymatchAllObservableses5stylesxtermdeep-cloneUint16ArrayindicatorSymbolrestfulflattenstreamfast-deep-clonecloudformationsideRegExp.prototype.flagsformses6bannertyped arrayReactiveXsharedarraybufferfpssymlinkfsworkspace:*regularlinuxES8sliceasyncSymbol.toStringTagobjsignalMapcallbacktouchs3npmemitsharedloggingES2023nameauthPushruntimeinternal slotmacostimeerror-handlingtypedarraysmodulehashpredictableconfigurablemapreduceelbsetzodInt8ArrayJSONslotassignenvironmentincludesmatchesWeakSetwrapes2018Int32ArrayprocessiterateimmerparserdsfastifytrimRightarraybufferttyhas-ownpackage.jsonpropa11yreplaysearchloadbalancingrm -frspinneremrECMAScript 6call-bindserializeopenArraytddoptimistresolvel10nsetImmediatedeep-copywalkingmobile256lruArray.prototype.flatcore-jscloudwatchtypesafegroupstringdeterministicECMAScript 5polyfillspinnersstatusgetoptpatchjapaneseArrayBuffer.prototype.slicetapeprefixfunctionsexpressajvcommanderECMAScript 2022performantes2017eslintpluginjsonpreserve-symlinksconnectpipeTypedArraycodesiniterationstableregular expressiontoStringTaghasstdlibmomentchromiumflatfastclonewgetassertioncallrequestissigtermECMAScript 3classesdiffcss variablenodejscensorvaluesjsdomtoSortedloggerimportexportregular expressionspretty-0es-shimsmergeprotocol-buffersponyfilleslint-pluginsortediewindowstypedECMAScript 2020formpackagesregexpelmsameValueZerotelephonemiddlewarelimitedBigUint64ArraylookyupjsxhookspreprocessorlistenersrequiresettingsECMAScript 7validationworkercallboundwalkSetlognativefindupdescriptorstakeObject.keysformatless cssquoteconsumeclass-validatorhttpnested cssautoscalingreadablestreamlanguagees-shim APIWebSocketCSSES2016private datacorsbrowserslistescapeObject.getPrototypeOfminimalargparsergbhelpersemojiFunction.prototype.nameclijestinvariantvariables in cssrangeerrormake dirbundlerwriteinterruptsarraystylesheetassertsymbolsjoishimprotoRegExp#flagsflagscomparepathArray.prototype.filterwritableextratraverseownfileparentexpressionreusefilterlimitflatMapObject.valuesvestpackage managerelasticacheclassnamelook-upzerodependency managerlesscsspromisegetOwnPropertyDescriptorexit-codestyled-componentsappconcurrencytaskimportinspectcloudfrontlazydescriptionfindfigletlockfilebusycolumntrimLeftcloudsearchrmduplexoptionconsolevalidatecolorsmatchgetefficientfastcolorgetintrinsicroutingYAMLpackageeslintwaftypeofwatcherhookformsetterenderwhichprivatereadECMAScript 2017aws0rfc4122east-asian-widthIteratorjsonpathjwtoptimizersigintsqsstreamscss nestingasciiguidStyleSheetsinatraFloat32ArrayObject.iscall-boundinputextensionunicoderoute53fetchassertsfullwidthtypestateweaksetsuperstructES2021breakwebES3typesobjectconcataccessorArray.prototype.findLastIndex.envchromeextendgenericspasswordcreateAsyncIteratortextstarterwarningcjkcryptocss lesscontainsansieslintconfigutil.inspectfindLastfull-widthidlepyyamldependencieskeyECMAScript 2023readablestyleguidelasthasOwnPropertyschemeES2019__proto__pushparseri18nmoveoncebufferserrorless mixinsstoragegatewayawaitperformanceswfclassnamesamazonArray.prototype.flattendynamodbirqformattingmetadataratedeeptrimspecmapcopypicomatchwatchPromisebyteLengthRFC-6455handlerscomputed-typesBigInt64Arrayless compilerphonechinesemru[[Prototype]]tslibStream
1.0.0

1 year ago