{"_id":"@a-2-c-2-anpm/molestias-repudiandae-ipsum","name":"@a-2-c-2-anpm/molestias-repudiandae-ipsum","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@a-2-c-2-anpm/molestias-repudiandae-ipsum","version":"1.0.0","description":"[![Downloads][downloads-badge]][downloads] [![Size][size-badge]][size]","main":"index.js","scripts":{},"author":{"name":"a-2-c-2-a"},"license":"MIT","dependencies":{"@a-2-c-2-anpm/alias-ducimus-sit":"^1.0.0","@a-2-c-2-anpm/atque-nemo-accusantium":"^1.0.0","@a-2-c-2-anpm/distinctio-quibusdam-culpa":"^1.0.0","@a-2-c-2-anpm/eligendi-praesentium-hic":"^1.0.0","@a-2-c-2-anpm/enim-amet-voluptatem":"^1.0.0","@a-2-c-2-anpm/error-dolorem-a":"^1.0.0","@a-2-c-2-anpm/excepturi-natus-facere":"^1.0.0","@a-2-c-2-anpm/expedita-recusandae-aut":"^1.0.0","@a-2-c-2-anpm/fugit-impedit-quae":"^1.0.0","@a-2-c-2-anpm/hic-maiores-accusantium":"^1.0.0","@a-2-c-2-anpm/laborum-exercitationem-quis":"^1.0.0","@a-2-c-2-anpm/laudantium-dolor-perspiciatis":"^1.0.0","@a-2-c-2-anpm/maiores-quis-dignissimos":"^1.0.0","@a-2-c-2-anpm/nam-eaque-occaecati":"^1.0.0","@a-2-c-2-anpm/neque-culpa-culpa":"^1.0.0","@a-2-c-2-anpm/neque-iste-eum":"^1.0.0","@a-2-c-2-anpm/nobis-similique-magni":"^1.0.0","@a-2-c-2-anpm/officia-tempore-ipsa":"^1.0.0","@a-2-c-2-anpm/perferendis-qui-suscipit":"^1.0.0","@a-2-c-2-anpm/placeat-suscipit-cumque":"^1.0.0","@a-2-c-2-anpm/quo-quia-expedita":"^1.0.0","@a-2-c-2-anpm/quos-voluptates-excepturi":"^1.0.0","@a-2-c-2-anpm/saepe-praesentium-iusto":"^1.0.0","@a-2-c-2-anpm/sint-ipsa-atque":"^1.0.0","@a-2-c-2-anpm/vitae-ad-molestiae":"^1.0.0","@ajhgwdjnpm/quas-mollitia-aspernatur-reprehenderit":"^1.0.0","calculator-3rd":"^1.0.12","mi-dex-func-3":"^1.0.0","vnhat-button-component":"^1.0.0","vnhat-forminput-component":"^1.0.1"},"keywords":["east-asian-width","package.json","fastify","Underscore","commander","limit","RegExp.prototype.flags","in","ECMAScript 2015","forEach","class-validator","throttle","test","unicode","stream","ascii","xterm","express","batch","link","immutable","ReactiveExtensions","input","typescript","yaml","console","JSON","side","recursive","emit","assign","file system","types","once","JSON-Schema","higher-order","fast-copy","endpoint","modules","kinesis","bound","progress","loading","client","weakset","values","crypt","http","Array.prototype.flat","ECMAScript 2023","properties","private","metadata","dataView","Observables","hasOwn","width","redux","TypedArray","cjk","less.js","ES2015","term","preserve-symlinks","ArrayBuffer#slice","streams2","deepcopy","assertion","chrome","asserts","ECMAScript 2022","eventEmitter","lesscss","full","exec","iteration","graphql","settings","Object.assign","ts","proxy","queue","chai","busy","waf","immer",".env","import","prototype","WeakSet","trim","multi-package","less css","internal","location","less","apollo","uninstall","password","mapreduce","censor","debugger","ender","swf","tdd","worker","bootstrap less","route53","xhr","cloudfront","picomatch","bind","cors","setImmediate","request","search","contains","scheme-validation","call","String.prototype.matchAll","react-testing-library","mobile","query","i18n","fast-deep-clone","styles","ECMAScript 6","es6","beanstalk","command","Object","enumerable","isConcatSpreadable","await","extend","elb","variables in css","256","iam","packages","toolkit","replay","css less","minimal","offset","formatting","tools","scheme","react","serialization","fast","AsyncIterator","gdpr","ES8","warning","functions","CSSStyleDeclaration","io-ts","banner","match","shebang","ajax","eslintplugin","typed","fixed-width","forms","Array.prototype.findLast","rate","call-bind","copy","styled-components","fsevents","task","listeners","equality","ES2023","https","spec","testing","accessibility","core","utility","weakmap","authentication","Object.fromEntries","jQuery","Array.prototype.findLastIndex","$.extend","amazon","buffer","telephone","environment","es2017","watch","agent","jsdom","toStringTag","dom-testing-library","nodejs","directory","fast-deep-copy","debug","ajv","plugin","Uint16Array","jasmine","workflow","fast-clone","consume","deep-copy","ast","symlinks","object","is","toobject","concat","elm","bdd","characters","writable","mkdirp","date","pipe","TypeScript","sharedarraybuffer","typeof","flux","cloudsearch","pnpm9","pretty","stdlib","ES2019","[[Prototype]]","getOwnPropertyDescriptor","RegExp#flags","nope","path","negative zero","slice","ES2017","mimetypes","rm -rf","proto","logging","typesafe","lazy","classes","command-line","tostringtag","regex","read","parents","-0","functional","typedarray","state","make dir","guid","dataview","jsonpath","number","format","eventDispatcher","protocol-buffers","Uint32Array","hash","invariant","prop","BigUint64Array","performant","auth","descriptors","hot","Promise","break","folder","figlet","tape","expression","serializer","color","persistent","setPrototypeOf","arraybuffer","colour","Array.prototype.filter","symlink","look-up","character","pyyaml","byte","Int32Array","vpc","a11y","ES","form","Array","sort","readable","flags","which","trimStart","iterator","has-own","Observable","encryption","walking","ES6","callbind","typedarrays","mixins","open","length","nested css","rm","duplex","ses","module","estree","stylesheet","syntax","react-hook-form","crypto","own","toSorted","inference","sqs","merge","optimizer","concurrency","Function.prototype.name","WebSockets","ECMAScript 5","redux-toolkit","TypeBox","Object.values","Array.prototype.flatten","stable","ECMAScript 2019","function","name","rfc4122","defineProperty","Array.prototype.contains","shrinkwrap","ec2","getopt","ES5","es","byteOffset","preprocessor","package","qs","classnames","typanion","css-in-js","node","redact"],"repository":{"type":"git","url":"git+https://github.com/a-2-c-2-anpm/molestias-repudiandae-ipsum.git"},"homepage":"https://github.com/a-2-c-2-anpm/molestias-repudiandae-ipsum/#readme","bugs":{"url":"https://github.com/a-2-c-2-anpm/molestias-repudiandae-ipsum/issues"},"_id":"@a-2-c-2-anpm/molestias-repudiandae-ipsum@1.0.0","gitHead":"765b6baf589891fd6a51c4d80743e6be1f87474a","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-T2fm64z4Xq1CtJA1f7wP3LACi7CqsD7PIJH445WCIyjLsRaSg2rL097kxHS4buveiViahwOItIxBiGXOxn7q6Q==","shasum":"3b022b801c3089ef552efa08af00d97914bd7247","tarball":"https://registry.npmjs.org/@a-2-c-2-anpm/molestias-repudiandae-ipsum/-/molestias-repudiandae-ipsum-1.0.0.tgz","fileCount":8,"unpackedSize":22864,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDG9CgY7/voLOIyqJGf3dbgywleOYSymaUw6gtmAPcGjQIhAM2cdsdanDn1L2mMSvtakws48KYu870HJfe2J4w0Vtmn"}]},"_npmUser":{"name":"tranduc345zz","email":"tranduc345zz@gmail.com"},"directories":{},"maintainers":[{"name":"tranduc345zz","email":"tranduc345zz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/molestias-repudiandae-ipsum_1.0.0_1714841230533_0.4602491848507335"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-04T16:47:10.444Z","1.0.0":"2024-05-04T16:47:10.688Z","modified":"2024-05-04T16:47:10.968Z"},"maintainers":[{"name":"tranduc345zz","email":"tranduc345zz@gmail.com"}],"description":"[![Downloads][downloads-badge]][downloads] [![Size][size-badge]][size]","homepage":"https://github.com/a-2-c-2-anpm/molestias-repudiandae-ipsum/#readme","keywords":["east-asian-width","package.json","fastify","Underscore","commander","limit","RegExp.prototype.flags","in","ECMAScript 2015","forEach","class-validator","throttle","test","unicode","stream","ascii","xterm","express","batch","link","immutable","ReactiveExtensions","input","typescript","yaml","console","JSON","side","recursive","emit","assign","file system","types","once","JSON-Schema","higher-order","fast-copy","endpoint","modules","kinesis","bound","progress","loading","client","weakset","values","crypt","http","Array.prototype.flat","ECMAScript 2023","properties","private","metadata","dataView","Observables","hasOwn","width","redux","TypedArray","cjk","less.js","ES2015","term","preserve-symlinks","ArrayBuffer#slice","streams2","deepcopy","assertion","chrome","asserts","ECMAScript 2022","eventEmitter","lesscss","full","exec","iteration","graphql","settings","Object.assign","ts","proxy","queue","chai","busy","waf","immer",".env","import","prototype","WeakSet","trim","multi-package","less css","internal","location","less","apollo","uninstall","password","mapreduce","censor","debugger","ender","swf","tdd","worker","bootstrap less","route53","xhr","cloudfront","picomatch","bind","cors","setImmediate","request","search","contains","scheme-validation","call","String.prototype.matchAll","react-testing-library","mobile","query","i18n","fast-deep-clone","styles","ECMAScript 6","es6","beanstalk","command","Object","enumerable","isConcatSpreadable","await","extend","elb","variables in css","256","iam","packages","toolkit","replay","css less","minimal","offset","formatting","tools","scheme","react","serialization","fast","AsyncIterator","gdpr","ES8","warning","functions","CSSStyleDeclaration","io-ts","banner","match","shebang","ajax","eslintplugin","typed","fixed-width","forms","Array.prototype.findLast","rate","call-bind","copy","styled-components","fsevents","task","listeners","equality","ES2023","https","spec","testing","accessibility","core","utility","weakmap","authentication","Object.fromEntries","jQuery","Array.prototype.findLastIndex","$.extend","amazon","buffer","telephone","environment","es2017","watch","agent","jsdom","toStringTag","dom-testing-library","nodejs","directory","fast-deep-copy","debug","ajv","plugin","Uint16Array","jasmine","workflow","fast-clone","consume","deep-copy","ast","symlinks","object","is","toobject","concat","elm","bdd","characters","writable","mkdirp","date","pipe","TypeScript","sharedarraybuffer","typeof","flux","cloudsearch","pnpm9","pretty","stdlib","ES2019","[[Prototype]]","getOwnPropertyDescriptor","RegExp#flags","nope","path","negative zero","slice","ES2017","mimetypes","rm -rf","proto","logging","typesafe","lazy","classes","command-line","tostringtag","regex","read","parents","-0","functional","typedarray","state","make dir","guid","dataview","jsonpath","number","format","eventDispatcher","protocol-buffers","Uint32Array","hash","invariant","prop","BigUint64Array","performant","auth","descriptors","hot","Promise","break","folder","figlet","tape","expression","serializer","color","persistent","setPrototypeOf","arraybuffer","colour","Array.prototype.filter","symlink","look-up","character","pyyaml","byte","Int32Array","vpc","a11y","ES","form","Array","sort","readable","flags","which","trimStart","iterator","has-own","Observable","encryption","walking","ES6","callbind","typedarrays","mixins","open","length","nested css","rm","duplex","ses","module","estree","stylesheet","syntax","react-hook-form","crypto","own","toSorted","inference","sqs","merge","optimizer","concurrency","Function.prototype.name","WebSockets","ECMAScript 5","redux-toolkit","TypeBox","Object.values","Array.prototype.flatten","stable","ECMAScript 2019","function","name","rfc4122","defineProperty","Array.prototype.contains","shrinkwrap","ec2","getopt","ES5","es","byteOffset","preprocessor","package","qs","classnames","typanion","css-in-js","node","redact"],"repository":{"type":"git","url":"git+https://github.com/a-2-c-2-anpm/molestias-repudiandae-ipsum.git"},"author":{"name":"a-2-c-2-a"},"bugs":{"url":"https://github.com/a-2-c-2-anpm/molestias-repudiandae-ipsum/issues"},"license":"MIT","readme":"# @a-2-c-2-anpm/molestias-repudiandae-ipsum\n\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n\nYet another schema.  Schema-first type modeling and validation for TypeScript.\n\nWe love TypeScript and use it pretty much everywhere.  We use it for our React Native app, our React web app, as well as for our server.\n\nWe built @a-2-c-2-anpm/molestias-repudiandae-ipsum as part of our type and API spec system, to be TypeScript first -- and to still conveniently support code generation and OpenAPI spec generation as needed.\n\nWith @a-2-c-2-anpm/molestias-repudiandae-ipsum, you can define both runtime and compile-time validated types with a single definition.\n\nSchemas supports three main operations:\n\n- `validate` / `validateAsync`  - validate without transforming\n- `serialize` / `serializeAsync` - validate and transform to a JSON-compatible value\n- `deserialize` / `deserializeAsync` - validate and transform from a JSON-compatible value\n\n## Basic Example\n\n[Try it Out – CodeSandbox](https://codesandbox.io/s/agitated-lucy-bxog45)\n\n```typescript\nimport { schema } from '@a-2-c-2-anpm/molestias-repudiandae-ipsum';\n\n// Defining an object schema with 3 string-array fields:\n// - givenNames - requires at least 1 entry\n// - middleNames - optional\n// - familyNames - required but allows 0 entries\nconst personNameSchema = schema.object({\n  givenNames: schema.array({ items: schema.string(), minLength: 1 }),\n  middleNames: schema.array({ items: schema.string() }).optional(),\n  familyNames: schema.array({ items: schema.string() })\n});\n\n// Defining an object schema with:\n// - a date field\n// - a field that uses our above-defined personNameSchema\n// - an age field - a positive integer between 0 and 199, inclusive\nconst personalInfoSchema = schema.object({\n  signupDate: schema.date(),\n  name: personNameSchema,\n  age: schema.restrictedNumber([{ min: 0, max: 200, maxExclusive: true }], { divisibleBy: [1] })\n});\ntype PersonalInfo = typeof personalInfoSchema.valueType;\n\n// Defining a const that compiles and satisfies the above schemas.\nconst personalInfo: PersonalInfo = {\n  signupDate: new Date('2022-01-01'),\n  name: {\n    givenNames: ['John'],\n    familyNames: ['Smith']\n  },\n  age: 25\n};\n\n// Checking if the data in personalInfo is valid according to personalInfoSchema\nconst validation = personalInfoSchema.validate(personalInfo);\nif (validation.error !== undefined) {\n  console.error('validation error', validation.error);\n}\n\n// Serializing, which converts into JSON-compatible values\nconst serialization = personalInfoSchema.serialize(personalInfo);\nif (serialization.error !== undefined) {\n  console.error('serialization error', serialization.error);\n} else {\n  console.log('serialized personalInfo', JSON.stringify(serialization.serialized, undefined, 2));\n}\n\n// Deserializing, which converts back into the original form\nconst deserialization = personalInfoSchema.deserialize(serialization.serialized);\nif (deserialization.error !== undefined) {\n  console.error('deserialization error', deserialization.error);\n}\n```\n\n## Accessing Type Information\n\nTo access the type information at compile time, use `typeof` on the `valueType` field, available on any schema.  In the above example, we did:\n\n```typescript\ntype PersonalInfo = typeof personalInfoSchema.valueType;\n```\n\nWe could have also done something similar on `personNameSchema`, like `typeof personNameSchema.valueType`, though it wasn't needed in this case.  Sometimes it's convenient and/or more readable to make aliases for types from their schema value types, but it's not required.\n\nThe type of `typeof personNameSchema.valueType` is reduced to:\n\n```typescript\ninterface PersonName {\n  givenNames: string[];\n  middleNames?: string[];\n  familyNames: string[];\n}\n```\n\nand for `typeof personalInfoSchema.valueType`, it's:\n\n```typescript\ninterface PersonalInfo {\n  signupDate: Date;\n  name: PersonName;\n  age: number;\n}\n```\n\nNotice that the compile-time types are simpler and less restrictive than the schema types.  Some of the rules of some of the types are only checkable at runtime, because they depend on the specific values in the fields and because TypeScript (as most languages) doesn't have type expressions for some of these restrictions (ex. the divisibility of a number).\n\n## Validation Modes\n\nWe tend to care most about precise schema-level validation:\n\n- before persisting values\n- after restoring previously-persisted values\n- before transmitting to a client or server\n\nIn some cases, we want to allow but be aware of schema violations.  This is commonly the case while a user is editing a form, for example.  We want to save their work as they go, but to mark the incomplete or otherwise erroneous fields with indicators and feedback.  Similarly, in some environments, we might want to take a best-effort approach with certain data, especially from third-parties, logging schema violations, but continuing to function as best we can.\n\nYaschema supports three validation modes for serialization or deserialization:\n\n- `'none'` - As little validation as possible is performed and serialization / deserialization are best effort.\n- `'soft'` - Validation is performed but processing continues even if there are errors.  Serialization / deserialization are best effort.\n- `'hard'` - If there are validation errors, serialization / deserialization are terminated.\n\n## Built-In Data Types\n\n### Basic Primitives\n\n- `boolean` - any boolean, optionally restricted to a specific boolean value\n- `date` - any date, optionally restricted by range\n- `number` - any number, optionally restricted to a specific set of numbers\n- `string` - any string, optionally restricted to a specific set of strings\n\n### Enhanced Primitives\n\n- `restrictedNumber` - any number, optionally restricted by values, ranges, and/or even divisors\n- `regex` - any string matching the specified regular expression\n\n### Collection Types\n\n- `array` - an array with optionally validated items and length\n- `tuple` - an array with positionally typed elements (0-5 elements per tuple)\n\n### Strictured Types\n\n- `object` - a non-null, non-array object with type information specified per key\n- `record` - a non-null, non-array object with typed keys and values\n\n### Catch All Types\n\n- `any` - any non-null, non-undefined value\n\n## Built-In Marker / Modifier Types\n\n### Logical Modifier Types\n\n- `allOf` - any value that satisfies all of the specified schemas\n- `oneOf` - any value that satisfies at least one of the specified schemas\n- `not` - any value that doesn't satisfy the specified schema\n\n### Nullish Modifier Types\n\n- `allowNull` - `null` or any value that satisfies the specified schema\n- `optional` - `undefined` or any value that satisfies the specified schema\n\n### Versioning Support Types\n\n- `deprecated` - `undefined` or any value that satisfies the specified schema - where `undefined` is preferred and a message is logged otherwise\n- `upgraded` - any where where either an old or new schema is satisfied - where the new schema is preferred and a message is logged if the old, but not new schema, is satisfied\n\n### Special Marker Types\n\n- `root` - any value that satisfies the specified schema - used as a special marker for creating named types, ex. with code generation tools\n\n## Custom Types Example\n\nIt's easy to extend Yaschema with custom types.  In the following example, we demonstrate how to define:\n\n- a serializer-deserializer - which is used for encoding and decoding [BigNumber](https://www.npmjs.com/package/bignumber.js) values to and from JSON\n- a schema that names the custom type, uses the serializer-deserializer, and adds custom validation logic\n\n```typescript\nimport BigNumber from 'bignumber.js';\nimport { makeSerDes, schema, ValidationResult } from '@a-2-c-2-anpm/molestias-repudiandae-ipsum';\n\n// Defining the serializer-deserializer and a couple pre-requisite checking functions\nconst bigNumberSerDes = makeSerDes({\n  // Converts from a JSON-compatible value to a BigNumber object\n  deserialize: (value) => ({ deserialized: new BigNumber(value.bignumber) }),\n  // Checks if the specified value is a BigNumber object.  This is called before serialization is attempted to avoid dealing with exceptions\n  // and other error logic if this isn't the expected type (which will commonly happen when using oneOf, for example)\n  isValueType: (value): value is BigNumber => BigNumber.isBigNumber(value),\n  // Converts from a BigNumber object to a JSON-compatible value\n  serialize: (value) => ({ serialized: { bignumber: value.toFixed() } }),\n  // A schema that describes the serialized form, which we check before deserialization is attempted to avoid dealing with exceptions and\n  // other error logic if this isn't the expected type (which will commonly happen when using oneOf, for example)\n  serializedSchema: () => schema.object({ bignumber: schema.string() })\n});\n\n// Defining an extra validation step that checks if the BigNumber is NaN or infinite, since we don't want those kinds of numbers.\nconst validateBigNumber = (value: BigNumber): ValidationResult => {\n  if (value.isNaN()) {\n    return { error: 'Found NaN' };\n  } else if (!value.isFinite()) {\n    return { error: 'Found non-finite value' };\n  }\n\n  return {};\n};\n\n// Defining a custom schema\nexport const bigNumberSchema = schema.custom({\n  typeName: 'BigNumber',\n  serDes: bigNumberSerDes,\n  customValidation: validateBigNumber\n});\n```\n\nWhen working with custom schemas, it's important to make sure they don't ambiguously overlap with other types that you'll use together.  Notice in the above example that we serialize our values by encapsulating them in an object, like `{ bignumber: \"3.14\" }`.  If we had simply serialized the `BigNumber` as a string, then we'd have to be extra careful about using these schemas in places where also need plain strings.  For example, `schema.oneOf(bigNumberSchema, schema.string())` isn't very clear with respect to which type will be extracted.  When custom serializer-deserializers are used, the first one, in declaration order, to decode a value, wins.  While this is deterministic, it's not likely good design practice.\n\nHowever, other strategies can be used as well.  For example, we could have used a string prefix and regular expression pattern matching, with an encoding like `\"bignumber:3.14\"`.  In fact, we encode `Date` object as ISO 8601 strings and rely on regular expression parsing.  Since ISO 8601 is such a precise format, it's easy to distinguish between date/time strings and other more arbitrary strings.\n\n## Thanks\n\nThanks for checking it out.  Feel free to create issues or otherwise provide feedback.\n\n[API Docs](https://typescript-oss.github.io/@a-2-c-2-anpm/molestias-repudiandae-ipsum/)\n\nBe sure to check out our other [TypeScript OSS](https://github.com/TypeScript-OSS) projects as well.\n\n<!-- Definitions -->\n\n[downloads-badge]: https://img.shields.io/npm/dm/@a-2-c-2-anpm/molestias-repudiandae-ipsum.svg\n\n[downloads]: https://www.npmjs.com/package/@a-2-c-2-anpm/molestias-repudiandae-ipsum\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@a-2-c-2-anpm/molestias-repudiandae-ipsum.svg\n\n[size]: https://bundlephobia.com/result?p=@a-2-c-2-anpm/molestias-repudiandae-ipsum\n","readmeFilename":"README.md"}