8 lines
9.6 KiB
Plaintext
8 lines
9.6 KiB
Plaintext
|
{
|
||
|
"version": 3,
|
||
|
"sources": ["../../src/errors/validation-error.ts"],
|
||
|
"sourcesContent": ["import type { Model } from '..';\nimport type { ErrorOptions } from './base-error';\nimport BaseError from './base-error';\n\n/**\n * An enum that is used internally by the `ValidationErrorItem` class\n * that maps current `type` strings (as given to ValidationErrorItem.constructor()) to\n * our new `origin` values.\n */\nexport enum ValidationErrorItemType {\n 'notnull violation' = 'CORE',\n 'string violation' = 'CORE',\n 'unique violation' = 'DB',\n 'validation error' = 'FUNCTION',\n}\n\n/**\n * An enum that defines valid ValidationErrorItem `origin` values\n */\nexport enum ValidationErrorItemOrigin {\n /**\n * specifies errors that originate from the sequelize \"core\"\n */\n CORE = 'CORE',\n\n /**\n * specifies validation errors that originate from the storage engine\n */\n DB = 'DB',\n\n /**\n * specifies validation errors that originate from validator functions (both built-in and custom) defined for a given attribute\n */\n FUNCTION = 'FUNCTION',\n}\n\n/**\n * Validation Error Item\n * Instances of this class are included in the `ValidationError.errors` property.\n */\nexport class ValidationErrorItem {\n /**\n * @deprecated Will be removed in v7\n */\n static TypeStringMap = ValidationErrorItemType;\n\n /**\n * @deprecated Will be removed in v7\n */\n static Origins = ValidationErrorItemOrigin;\n\n /**\n * An error message\n */\n readonly message: string;\n\n /**\n * The type/origin of the validation error\n */\n readonly type: keyof typeof ValidationErrorItemType | null;\n\n /**\n * The field that triggered the validation error\n */\n readonly path: string | null;\n\n /**\n * The value that generated the error\n */\n readonly value: string | null;\n\n readonly origin: keyof typeof ValidationErrorItemOrigin | null;\n\n /**\n * The DAO instance that caused the validation error\n */\n readonly instance: Model | null;\n\n /**\n * A validation \"key\", used for identification\n */\n readonly validatorKey: string | null;\n\n /**\n * Property name of the BUILT-IN validator function that caused the validation error (e.g. \"in\" or \"len\"), if applicable\n */\n readonly validatorName: string | null;\n\n /**\n * Parameters used with the BUILT-IN validator function, if applicable\n */\n readonly validatorArgs: unknown[];\n\n /**\n * Creates a new ValidationError item. Instances of this class are included in the `ValidationError.errors` property.\n *\n * @param message An error message\n * @param type The type/origin of the validation error\n * @param path The field that triggered the validation error\n * @param value The value that generated the error\n * @param instance the DAO instance that caused the validation error\n * @param validatorKey a validation \"key\", used for identification\n * @param fnName property name of the BUILT-IN validator function that caused the validation error (e.g. \"in\" or \"len\"), if applicable\n * @param fnArgs parameters used with the BUILT-IN validator function, if applicable\n */\n constructor(\n message: string,\n type:\n | keyof typeof ValidationErrorItemType\n | keyof typeof ValidationErrorItemOrigin,\n path: string,\n value: string,\n instance: Model,\n validatorKey: string,\n fnName: string,\n fnArgs: unknown[]\n ) {\n this.message = message || '';\n this.type = null;\n this.path = path || null;\n\n this.value = value !== undefined ? value : null;\n\n this.origin = null;\n\n this.instance = instance || null;\n\n this.validatorKey = validatorKey || null;\n\n this.validatorName = fnName || null;\n\n this.validatorArgs = fnArgs || [];\n\n if (type) {\n if (this.isValidationErrorItemOrigin(type)) {\n this.origin = type;\n } else {\n const lowercaseType = this.normalizeString(type);\n const realType = ValidationErrorItemType[lowercaseType];\n\n if (realType && ValidationErrorItemOrigin[realType]) {\n this.origin = realType;\n this.type = ty
|
||
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAAsB;AAOf,IAAK,0BAAL,kBAAK,6BAAL;AACL,kDAAsB;AACtB,iDAAqB;AACrB,iDAAqB;AACrB,iDAAqB;AAJX;AAAA;AAUL,IAAK,4BAAL,kBAAK,+BAAL;AAIL,uCAAO;AAKP,qCAAK;AAKL,2CAAW;AAdD;AAAA;AAqBL,0BAA0B;AAAA,EAiE/B,YACE,SACA,MAGA,MACA,OACA,UACA,cACA,QACA,QACA;AA9DO;AAKA;AAKA;AAKA;AAEA;AAKA;AAKA;AAKA;AAKA;AA0BP,SAAK,UAAU,WAAW;AAC1B,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AAEpB,SAAK,QAAQ,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