4.6.128 • Published 10 months ago

@diotoborg/esse-perspiciatis-voluptatem v4.6.128

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Doormen

Validate, sanitize and assert: the silver bullet of data!

Beta version.

/!\ This documentation is still a Work In Progress /!\

Basic validation

  • sanitize Array of string the sanitizer's name to apply before any type checking
  • optional boolean the data can be null or undefined, if so the data validate immediately
  • default (anything) the data can be null or undefined, if so it is overwritten by the default value and it validates immediately
  • type string the name of the type checker
  • instanceOf
  • min
  • max
  • length
  • minLength
  • maxLength
  • match
  • in
  • notIn
  • when
  • properties object of schema, it iterates through each properties and checks that they all match their own schema
  • elements Array same than properties but for arrays
  • only boolean used in conjunction with properties or elements, it checks that no properties other than those listed are present
  • of object contains one schema that will check each elements of an array or each properties

Type Checkers

Javascript primitive types:

  • undefined: the data should be undefined
  • null: the data should be null
  • boolean: the data should be a boolean, i.e. true or false
  • number: the data should be a number. NOTE that Infinity and NaN are ok, so you may consider using real/float instead of number in almost all cases
  • string: the data should be a string
  • object: the data should be an Object
  • function: the data should be a Function

Javascript/Node.js built-in types:

  • array: the data should be an Array
  • error: the data should be an instance of Error
  • date: the data should be an instance of Date
  • regexp: a regular expression
  • buffer: the data should be a Node.js Buffer

Common meta types:

  • unset: null or undefined
  • real or float: a number that is not NaN nor +/- Infinity
  • integer: a number that is not NaN nor +/- Infinity, and that do not have decimal part
  • hex: a string representing an hexadecimal number, having only 0-9, a-f and A-F characters
  • strictObject: an object that is not an array
  • looseObject: object-like: object or function

Internet:

  • ipv4: a string that is a IPv4 address
  • ipv6: a string that is a IPv6 address
  • ip: an IPv4 or IPv6 address
  • hostname: a string that is a valid hostname (domain + subdomain)
  • host: a hostname or an ip address
  • url: a string that is a valid URL (generic URL) including the scheme
  • weburl: a valid web/internet URL, a subset of the URL type
  • email: a string that is a valid email address

Misc:

  • schema: an object which is a valid @diotoborg/esse-perspiciatis-voluptatem schema
  • mongoId: an object which is a MongoDB's ObjectId OR a string that is a correct ObjectId string representation

Sanitizers

Common cast:

  • toNumber: try to convert to a number (mostly from string)
  • toReal or toFloat: try to convert to a float/real (not much difference with toNumber)
  • toInteger: try to convert to an integer, rounding the number if necessary
  • toString: try to convert to a string
  • toBoolean: try to convert to a boolean very loosely, so it accepts strings like true/false, yes/no, on/off or numbers like 1/0, or fallback to truthy/falsy values.
  • toArray: try to convert to an array, non-array are converted to an array with a single element
  • toDate: try to convert to a Date (number are timestamp, string are parsed, object are considered like a Date-object)
  • nullToUndefined: transform null to undefined

String modifiers:

  • trim: trim the string, removing whitespace at the beginning and the end
  • toUpperCase: transform all characters into their upper-case counterparts
  • toLowerCase: transform all characters into theier lower-case counterparts
  • capitalize: transform to title case, each word starts with an upper-case
  • titleCase: transform to title case, each word starts with an upper-case following lower-case characters (except ALL-CAPS words)
  • latinize: transform letter to latin (remove accent, transform modified letters to their latin counterparts)
  • dashToCamelCase: transform identifiers having word separated by dash/hyphen to camelCase

Enforcers:

  • resize: resize a string if it does not match the required length/minLength/maxLength (truncate, or use leftPadding/rightPadding properties of the schema)
  • removeExtraProperties: remove extra-properties from the object that are not in the schema (clone it, not in-place)

Misc:

  • mongoId: convert a string to a MongoDB's ObjectId if possible
namespolyfillReactiveExtensionsgetoptparsingRFC-6455phonetypanionresolveopensquoterobustvalidatejsnopecloudsearcheventEmitterfunctionalsetterenvironmentswaffindLastredux-toolkitroutefigletshellcmditerationmetadatasimpledbutilitiesspawni18nArray.prototype.findLastIndexprivateStreamshookspushpyyamlutil.inspectchinesedataViewboundES2019statelessrecursivefromES2021createwaitclass-validator__proto__japanesetermeslintobjectwebsiteWeakMapfast-copycontainsstreamsrfc4122concatpropertiespopmotionlogarraydefinePropertysymbolmime-dbcloudwatchxdgtelephonerateflatMapmatchAllargvpackageenvironmentkey parregular expressionexecpropertypackage.jsonttysometrimEndwhatwgtypedarraysfile cacheprunefindimportexportregexconvertio-tslaunchdeletereusees7eventDispatchernpmvisualcallbackclonepositivewarningparseexpressionthreelengthroute53graphqlsetyupdescriptorsstdlibamazonbreakgesturesreact-hook-formsidebrowserlistjavascriptmkdirsmimetypesES5ecmascriptstyleObjectaccessorlimitedflattentypescriptefficientvalidationimmutablequeryparentieconsumes3ArrayBuffer#slicekeyszodbundlersyntaxerrorcolumnsAsyncIteratorpipeenvlistenerstouchredirectlookrangeerrorES7utilityoffsetterminalawesomesaucergbsetPrototypeOfjsonpathajvnumberidtrimRightcommanddropisloggerfile systemsetImmediateHyBicloudformationfastcloudtrailArrayBuffer.prototype.slicecircularformsfetchinternaldebugdomestreetoolkitconfigurablebuffersreact animationasyncchildprotobuflanguageautoscalingrm -frtoArrayfilter256arraysarktyperdsTypeBoxes-shim APIbddminimalarraybufferoptimizerjQueryWeakSeteditorworkspace:*karmaebses-abstractjestfind-upagentbyteLengthArray.prototype.flatjsdiffqueueMicrotaskreadablestreamunicodenativegetOwnPropertyDescriptordragES2023installdescriptiones6bindinternal slotnodejsECMAScript 2017hasObservablecryptostarterFunction.prototype.namediffreduxtestidleassertioncjkdependenciesbrowserdeepelectronruntimeRxIteratorreact poseMicrosoftes2018rmdirfunctionArray.prototype.flattenoptimistArrayES2022dynamodbcharactermatchjsonvariablesES2017groupBytyped arrayxhrObservables_.extendtypesafecollectionsesURLObject.entriesendpointtoSortedtostringtaglastpromisebyteOffsetcompilershrinkwraprm -rfsharedarraybufferopenerspeedassertsUint32Arrayclirapidqueueswfthrottleeslintconfigjoicsspatch[[Prototype]]propserializeajaxstylingshamstreammapreducetoobjectcolorsutildirectoryFloat32Arrayclienttapformatentriesreadabletc39outputtypeString.prototype.trimsymlinksweakseticonvmodulesbatchprotocol-buffersairbnbArray.prototype.flatMapapiArrayBuffertrimes2015snswalkweakmapsuperagentgroupwhichfpsidentifiersdom-testing-librarybrowserslistvestreduceformattingcachefindLastIndextsliblibphonenumberflatCSSview.enverrortoolslocationhttpassertargumentsurljsdommatchesmonoreporandomguidfunctionscomputed-typesenumerablesettingsJSONECMAScript 2023Object.fromEntriesisConcatSpreadablextermshebangworkeroptionsortinvariantES6trimStartECMAScript 6callmkdircall-bindESnextredactindicatorhelperswaapiastuninstallECMAScript 2016negative zeroratelimitpatheventsgenericsemitfastclonestoragegatewaystableloadbalancingBigUint64Arrayexpressprototypereact-hooksPromiseequalitydirinputdataviewWebSocketwalkingECMAScript 2020assigngdprobjchromiumframerstreams2everytypedarrayObject.keysprotoconsolelrutypedprivate datakey valuees8fixed-widthObject.isArray.prototype.findLasthelperappPushponyfilltypesposebluebirdcloudfronthttpspromisescommanderchecktddcopyURLSearchParamsuptestingsaferequireWebSocketsglobcompareduplexinstrumentationcensorjasmineStreamargumentECMAScript 5ECMAScript 7RxJSwordwrapArray.prototype.containsrmextendmergefastifycharacterscore-jschaidependency managerprocessuuidformmapbusyescapecolumncharsetdayjses2017hardlinksfast-deep-copyInt16ArrayES2015beanstalkstringifytraversetypeofremoveserializerstartObject.assignsymbolsiterateautoprefixera11yObject.getPrototypeOfpicomatchbundlingmrulockfilejson cachegetterInt32Arrayfull-widthonceUint8ClampedArraymobileopenhasOwnhookformmochaschemamomentinstallerconcurrencyYAMLECMAScript 2018kinesisprettydaterequestinferenceSetObject.definePropertyspecbufferloggingfullwidthawaitlook-upspinnersmovefilereal-timestructuredClonehashthroatstringifierregular expressions3dtapesqsconcatMapslotproxystyled-componentspackageschrome$.extendUint16ArrayregularUint8ArrayTypeScriptec2accessibilityartstringansipluginpreserve-symlinkssameValueZerosymlinkFloat64Arraysearchlimitdeterministiczerocoveragestyleguidetasksimple cachecode pointsreadsliceroutingcollection.es6flagtextinReflect.getPrototypeOfform-validationwgetes-shimsspinnerpersistenttoStringTagwritablecommand-lineperformanceistanbulfindupscheme-validationcss-in-jsquerystringjshintcallbounddebuggerapolloObject.valuesES8linkmulti-packagefullcurlfast-cloneomitconfigbannertypeerrorimportkeyprefixwriteavadeepcopyintrinsicl10nemojiMapBigInt64ArrayECMAScript 2021iamkoreaneast-asian-widtheslint-pluginSymboles2016valueInt8ArraychanneldefaultES2016xdg-openlazyJSON-SchemaequalparserespreedeepclonewrapbytecoreString.prototype.matchAllCSSStyleDeclarationStyleSheetECMAScript 2019reactjsxECMAScript 3definenodelinewrapcallbindnamegetES2020executableReactiveXpostcssmakeSymbol.toStringTagspringnegativeelbasciiforEachsortedglobalsdescriptorawshigher-orderTypedArray
4.5.120

10 months ago

4.5.121

10 months ago

3.2.107

11 months ago

3.2.106

11 months ago

3.2.108

11 months ago

2.0.37

1 year ago

2.0.38

1 year ago

2.0.35

1 year ago

2.0.36

1 year ago

4.5.119

10 months ago

3.1.67

1 year ago

3.1.66

1 year ago

3.1.69

1 year ago

3.1.68

1 year ago

3.1.61

1 year ago

3.1.60

1 year ago

3.1.63

1 year ago

3.1.62

1 year ago

3.1.65

1 year ago

2.0.39

1 year ago

3.1.64

1 year ago

2.0.48

1 year ago

2.0.49

1 year ago

2.0.46

1 year ago

2.0.47

1 year ago

2.0.44

1 year ago

2.0.45

1 year ago

2.0.42

1 year ago

2.0.43

1 year ago

2.0.40

1 year ago

2.0.41

1 year ago

3.4.115

11 months ago

3.4.116

11 months ago

3.4.117

10 months ago

2.0.51

1 year ago

2.0.50

1 year ago

3.4.111

11 months ago

3.2.97

11 months ago

3.4.112

11 months ago

3.2.96

11 months ago

3.4.113

11 months ago

3.2.99

11 months ago

3.4.114

11 months ago

3.2.98

11 months ago

3.2.103

11 months ago

3.2.102

11 months ago

3.2.105

11 months ago

3.2.104

11 months ago

3.2.101

11 months ago

3.2.100

11 months ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

3.1.92

11 months ago

3.1.91

11 months ago

3.1.94

11 months ago

3.1.93

11 months ago

3.1.96

11 months ago

3.1.95

11 months ago

4.6.121

10 months ago

4.6.122

10 months ago

3.1.90

11 months ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

2.1.58

1 year ago

2.1.59

1 year ago

2.1.56

1 year ago

2.1.57

1 year ago

2.1.54

1 year ago

2.1.55

1 year ago

2.1.52

1 year ago

1.0.33

1 year ago

2.1.53

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

2.1.51

1 year ago

1.0.30

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

3.1.78

12 months ago

3.5.117

10 months ago

3.1.77

12 months ago

3.1.79

12 months ago

3.5.118

10 months ago

3.5.119

10 months ago

3.1.70

12 months ago

3.1.72

12 months ago

3.1.71

12 months ago

3.1.74

12 months ago

3.1.73

12 months ago

3.1.76

12 months ago

3.1.75

12 months ago

2.1.60

1 year ago

3.1.89

12 months ago

3.1.88

12 months ago

3.3.110

11 months ago

3.3.111

11 months ago

3.1.81

12 months ago

3.1.80

12 months ago

4.6.127

10 months ago

3.1.83

12 months ago

4.6.128

10 months ago

3.1.82

12 months ago

4.6.125

10 months ago

3.1.85

12 months ago

4.6.126

10 months ago

3.1.84

12 months ago

4.6.123

10 months ago

3.1.87

12 months ago

4.6.124

10 months ago

3.1.86

12 months ago

3.3.109

11 months ago

1.0.15

1 year ago

3.3.108

11 months ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.9

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.12

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago