@simplysm/sd-core-common
Advanced tools
Comparing version 3.1.142 to 3.1.152
export declare function PropertyGetSetDecoratorBase<O, K extends keyof O>(arg: { | ||
beforeSet?: (target: O, propertyName: K, oldValue: O[K], newValue: O[K]) => ((() => O[K]) | void); | ||
beforeSet?: (target: O, propertyName: K, oldValue: O[K], newValue: O[K]) => (O[K] | void); | ||
afterSet?: (target: O, propertyName: K, oldValue: O[K], newValue: O[K]) => void; | ||
get?: (target: O, propertyName: K, value: O[K]) => void; | ||
}): (target: O, propertyName: K, inputDescriptor?: PropertyDescriptor) => void; |
@@ -24,3 +24,3 @@ "use strict"; | ||
if (beforeSetResult) { | ||
realValue = beforeSetResult(); | ||
realValue = beforeSetResult; | ||
} | ||
@@ -27,0 +27,0 @@ } |
@@ -11,3 +11,3 @@ "use strict"; | ||
if (error) { | ||
throw new Error(`입력값이 잘못되었습니다: ${JSON.stringify({ | ||
throw new Error(`${error.message ? error.message : "입력값이 잘못되었습니다"}: ${JSON.stringify({ | ||
component: target.constructor.name, | ||
@@ -19,2 +19,3 @@ propertyName, | ||
} | ||
return replacedNextValue; | ||
} | ||
@@ -21,0 +22,0 @@ }); |
@@ -29,3 +29,3 @@ import { Type, TypeWrap } from "../commons"; | ||
}; | ||
distinct(): T[]; | ||
distinct(matchAddress?: boolean): T[]; | ||
orderBy(selector?: (item: T) => string | number): T[]; | ||
@@ -32,0 +32,0 @@ orderByDesc(selector?: (item: T) => string | number): T[]; |
@@ -87,6 +87,6 @@ "use strict"; | ||
}; | ||
Array.prototype.distinct = function () { | ||
Array.prototype.distinct = function (matchAddress) { | ||
const result = []; | ||
for (const item of this) { | ||
if (!result.some((item1) => ObjectUtil_1.ObjectUtil.equal(item1, item))) { | ||
if (!result.some((item1) => matchAddress ? item1 === item : ObjectUtil_1.ObjectUtil.equal(item1, item))) { | ||
result.push(item); | ||
@@ -93,0 +93,0 @@ } |
@@ -11,3 +11,2 @@ import "core-js"; | ||
import "./extension/ArrayExtension"; | ||
export * from "./index"; | ||
export * from "./type/DateOnly"; | ||
@@ -14,0 +13,0 @@ export * from "./type/DateTime"; |
@@ -14,3 +14,2 @@ "use strict"; | ||
require("./extension/ArrayExtension"); | ||
tslib_1.__exportStar(require("./index"), exports); | ||
tslib_1.__exportStar(require("./type/DateOnly"), exports); | ||
@@ -17,0 +16,0 @@ tslib_1.__exportStar(require("./type/DateTime"), exports); |
@@ -38,3 +38,3 @@ import { Type, TypeWrap } from "../commons"; | ||
includes?: T[]; | ||
validator?: (value: T) => boolean; | ||
validator?: (value: T) => boolean | string; | ||
} | ||
@@ -46,2 +46,3 @@ export interface IValidateResult<T> { | ||
}; | ||
message?: string; | ||
} | ||
@@ -48,0 +49,0 @@ declare type TValidateObjectDef<T> = { |
@@ -157,4 +157,13 @@ "use strict"; | ||
} | ||
if (currDef.validator && !currDef.validator(value)) { | ||
invalidateDef.validator = currDef.validator; | ||
let message; | ||
if (currDef.validator) { | ||
const validatorResult = currDef.validator(value); | ||
if (validatorResult === true) { | ||
} | ||
else { | ||
invalidateDef.validator = currDef.validator; | ||
if (typeof validatorResult === "string") { | ||
message = validatorResult; | ||
} | ||
} | ||
} | ||
@@ -165,3 +174,3 @@ if (currDef.includes && !currDef.includes.includes(value)) { | ||
if (Object.keys(invalidateDef).length > 0) { | ||
return { value, invalidateDef }; | ||
return { value, invalidateDef, message }; | ||
} | ||
@@ -168,0 +177,0 @@ return undefined; |
{ | ||
"name": "@simplysm/sd-core-common", | ||
"version": "3.1.142", | ||
"version": "3.1.152", | ||
"description": "심플리즘 패키지 - 코어 모듈 (browser/node)", | ||
@@ -5,0 +5,0 @@ "author": "김석래", |
const symbol = `sd-type-validate`; | ||
export function PropertyGetSetDecoratorBase<O, K extends keyof O>(arg: { | ||
beforeSet?: (target: O, propertyName: K, oldValue: O[K], newValue: O[K]) => ((() => O[K]) | void); | ||
beforeSet?: (target: O, propertyName: K, oldValue: O[K], newValue: O[K]) => (O[K] | void); | ||
afterSet?: (target: O, propertyName: K, oldValue: O[K], newValue: O[K]) => void; | ||
@@ -32,3 +32,3 @@ get?: (target: O, propertyName: K, value: O[K]) => void; | ||
if (beforeSetResult) { | ||
realValue = beforeSetResult(); | ||
realValue = beforeSetResult; | ||
} | ||
@@ -35,0 +35,0 @@ } |
@@ -10,3 +10,3 @@ import {PropertyGetSetDecoratorBase} from "./PropertyGetSetDecoratorBase"; | ||
if (error) { | ||
throw new Error(`입력값이 잘못되었습니다: ${JSON.stringify({ | ||
throw new Error(`${error.message ? error.message : "입력값이 잘못되었습니다"}: ${JSON.stringify({ | ||
component: target.constructor.name, | ||
@@ -18,4 +18,6 @@ propertyName, | ||
} | ||
return replacedNextValue; | ||
} | ||
}); | ||
} |
@@ -37,3 +37,3 @@ import {Type, TypeWrap} from "../commons"; | ||
distinct(): T[]; | ||
distinct(matchAddress?: boolean): T[]; | ||
@@ -172,6 +172,6 @@ orderBy(selector?: (item: T) => string | number): T[]; | ||
Array.prototype.distinct = function <T>(this: T[]): T[] { | ||
Array.prototype.distinct = function <T>(this: T[], matchAddress?: boolean): T[] { | ||
const result: T[] = []; | ||
for (const item of this) { | ||
if (!result.some((item1) => ObjectUtil.equal(item1, item))) { | ||
if (!result.some((item1) => matchAddress ? item1 === item : ObjectUtil.equal(item1, item))) { | ||
result.push(item); | ||
@@ -178,0 +178,0 @@ } |
@@ -11,3 +11,2 @@ import "core-js"; | ||
import "./extension/ArrayExtension"; | ||
export * from "./index"; | ||
export * from "./type/DateOnly"; | ||
@@ -14,0 +13,0 @@ export * from "./type/DateTime"; |
@@ -196,4 +196,14 @@ import {DateTime} from "../type/DateTime"; | ||
if (currDef.validator && !currDef.validator(value as any)) { | ||
invalidateDef.validator = currDef.validator; | ||
let message: string | undefined; | ||
if (currDef.validator) { | ||
const validatorResult = currDef.validator(value as any); | ||
if (validatorResult === true) { | ||
} | ||
else { | ||
invalidateDef.validator = currDef.validator; | ||
if (typeof validatorResult === "string") { | ||
message = validatorResult; | ||
} | ||
} | ||
} | ||
@@ -206,3 +216,3 @@ | ||
if (Object.keys(invalidateDef).length > 0) { | ||
return {value, invalidateDef}; | ||
return {value, invalidateDef, message}; | ||
} | ||
@@ -312,3 +322,3 @@ | ||
includes?: T[]; | ||
validator?: (value: T) => boolean; | ||
validator?: (value: T) => boolean | string; | ||
} | ||
@@ -319,2 +329,3 @@ | ||
invalidateDef: IValidateDef<T> & { type?: Type<TypeWrap<T>>[] }; | ||
message?: string; | ||
} | ||
@@ -321,0 +332,0 @@ |
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
Sorry, the diff of this file is too big to display
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
441206
6076