@galaxar/types
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -38,4 +38,7 @@ "use strict"; | ||
let fullMessage = error.message; | ||
if (error.info.path) { | ||
fullMessage += ' Key: ' + error.info.path; | ||
} | ||
if (error.info.error) { | ||
fullMessage += ' ' + error.info.error; | ||
fullMessage += '\n' + error.info.error; | ||
} | ||
@@ -42,0 +45,0 @@ if (error.info.errors) { |
@@ -13,2 +13,3 @@ "use strict"; | ||
const _every = /*#__PURE__*/ _interop_require_default(require("lodash/every")); | ||
const _mapValues = /*#__PURE__*/ _interop_require_default(require("lodash/mapValues")); | ||
const _errors = require("./errors"); | ||
@@ -104,2 +105,10 @@ const _objectPathUtils = require("@galaxar/utils/objectPathUtils"); | ||
} | ||
const { valueSchema , ..._meta } = meta; | ||
if (valueSchema) { | ||
const schema = (0, _mapValues.default)(value, ()=>valueSchema); | ||
return this._sanitize(value, { | ||
schema, | ||
..._meta | ||
}, opts); | ||
} | ||
return value; | ||
@@ -160,2 +169,10 @@ } | ||
} | ||
const { valueSchema , ..._meta } = meta; | ||
if (valueSchema) { | ||
const schema = (0, _mapValues.default)(value, ()=>valueSchema); | ||
return this._sanitizeAsync(value, { | ||
schema, | ||
..._meta | ||
}, opts); | ||
} | ||
return value; | ||
@@ -241,5 +258,4 @@ } | ||
} | ||
; | ||
const _default = T_OBJECT; | ||
//# sourceMappingURL=object.js.map |
@@ -120,2 +120,5 @@ "use strict"; | ||
return (value, typeInfo, i18n, fieldPath)=>{ | ||
if (typeInfo.type == null) { | ||
throw new _errors.InvalidArgument(`Missing type info: ${JSON.stringify(typeInfo)}`); | ||
} | ||
if (!this.primitives.has(typeInfo.type)) { | ||
@@ -122,0 +125,0 @@ throw new _errors.InvalidArgument(`Unsupported primitive type: "${typeInfo.type}".`); |
@@ -16,4 +16,8 @@ import { ExposableError, ApplicationError } from './AppErrors'; | ||
let fullMessage = error.message; | ||
if (error.info.path) { | ||
fullMessage += ' Key: ' + error.info.path; | ||
} | ||
if (error.info.error) { | ||
fullMessage += ' ' + error.info.error; | ||
fullMessage += '\n' + error.info.error; | ||
} | ||
@@ -20,0 +24,0 @@ |
import _each from 'lodash/each'; | ||
import _every from 'lodash/every'; | ||
import _mapValues from 'lodash/mapValues'; | ||
import { ValidationError } from './errors'; | ||
@@ -26,7 +27,7 @@ import { makePath } from '@galaxar/utils/objectPathUtils'; | ||
let _fieldValue; | ||
let _fieldValue; | ||
if (Array.isArray(validationObject)) { | ||
const errors = []; | ||
const foudMatched = validationObject.find(_validationObject => { | ||
const foudMatched = validationObject.find((_validationObject) => { | ||
try { | ||
@@ -46,5 +47,5 @@ _fieldValue = this.system.sanitize(fieldValue, _validationObject, opts.i18n, fieldPath); | ||
rawValue: opts.rawValue, | ||
i18n: opts.i18n, | ||
i18n: opts.i18n, | ||
path: fieldPath, | ||
errors | ||
errors, | ||
}); | ||
@@ -56,3 +57,3 @@ } | ||
if (_fieldValue != null || (fieldName in value)) { | ||
if (_fieldValue != null || fieldName in value) { | ||
newValue[fieldName] = _fieldValue; | ||
@@ -66,7 +67,7 @@ } | ||
let _fieldValue; | ||
let _fieldValue; | ||
if (Array.isArray(validationObject)) { | ||
const errors = []; | ||
const foudMatched = await findAsync_(validationObject, async _validationObject => { | ||
const foudMatched = await findAsync_(validationObject, async (_validationObject) => { | ||
try { | ||
@@ -86,5 +87,5 @@ _fieldValue = await this.system.sanitize_(fieldValue, _validationObject, opts.i18n, fieldPath); | ||
rawValue: opts.rawValue, | ||
i18n: opts.i18n, | ||
i18n: opts.i18n, | ||
path: fieldPath, | ||
errors | ||
errors, | ||
}); | ||
@@ -137,3 +138,3 @@ } | ||
try { | ||
_each(altSchema, this._sanitizeMember(value, opts, newValue)); | ||
_each(altSchema, this._sanitizeMember(value, opts, newValue)); | ||
return true; | ||
@@ -153,3 +154,3 @@ } catch (error) { | ||
path: opts.path, | ||
errors | ||
errors, | ||
}); | ||
@@ -169,2 +170,8 @@ } | ||
const { valueSchema, ..._meta } = meta; | ||
if (valueSchema) { | ||
const schema = _mapValues(value, () => valueSchema); | ||
return this._sanitize(value, { schema, ..._meta }, opts); | ||
} | ||
return value; | ||
@@ -201,3 +208,3 @@ } | ||
try { | ||
await batchAsync_(altSchema, this._sanitizeMember_(value, opts, newValue)); | ||
await batchAsync_(altSchema, this._sanitizeMember_(value, opts, newValue)); | ||
return true; | ||
@@ -217,3 +224,3 @@ } catch (error) { | ||
path: opts.path, | ||
errors | ||
errors, | ||
}); | ||
@@ -233,2 +240,8 @@ } | ||
const { valueSchema, ..._meta } = meta; | ||
if (valueSchema) { | ||
const schema = _mapValues(value, () => valueSchema); | ||
return this._sanitizeAsync(value, { schema, ..._meta }, opts); | ||
} | ||
return value; | ||
@@ -241,4 +254,4 @@ } | ||
} | ||
}; | ||
} | ||
export default T_OBJECT; |
@@ -93,2 +93,6 @@ import { InvalidArgument, ValidationError, ApplicationError } from './errors'; | ||
return (value, typeInfo, i18n, fieldPath) => { | ||
if (typeInfo.type == null) { | ||
throw new InvalidArgument(`Missing type info: ${JSON.stringify(typeInfo)}`); | ||
} | ||
if (!this.primitives.has(typeInfo.type)) { | ||
@@ -95,0 +99,0 @@ throw new InvalidArgument(`Unsupported primitive type: "${typeInfo.type}".`); |
{ | ||
"name": "@galaxar/types", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Galaxar Semantic Data Types", | ||
@@ -27,3 +27,3 @@ "main": "cjs/index.js", | ||
"lodash": "^4.17.21", | ||
"@galaxar/utils": "1.0.8" | ||
"@galaxar/utils": "1.0.9" | ||
}, | ||
@@ -30,0 +30,0 @@ "nyc": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158366
2710
+ Added@galaxar/utils@1.0.9(transitive)
- Removed@galaxar/utils@1.0.8(transitive)
Updated@galaxar/utils@1.0.9