@flatfile/hooks
Advanced tools
Comparing version 1.2.4 to 1.3.0
@@ -69,2 +69,5 @@ type TPrimitive = string | boolean | number | null; | ||
pushInfoMessage(fields: string | string[], message: string, level: IRecordInfo['level'], stage: TRecordStageLevel): this; | ||
compute(field: string, transformation: (value: TPrimitive, record: FlatfileRecord<M>) => TPrimitive, message?: string): this; | ||
computeIfPresent(field: string, transformation: (value: TPrimitive, record: FlatfileRecord<M>) => TPrimitive, message?: string): this; | ||
validate(field: string, validator: (value: TPrimitive, record: FlatfileRecord<M>) => boolean, message: string): this; | ||
toJSON(): IRawRecordWithInfo<M>; | ||
@@ -71,0 +74,0 @@ } |
@@ -161,2 +161,21 @@ "use strict"; | ||
} | ||
compute(field, transformation, message) { | ||
this.set(field, transformation(this.get(field), this)); | ||
if (message) { | ||
this.addComment(field, message); | ||
} | ||
return this; | ||
} | ||
computeIfPresent(field, transformation, message) { | ||
if (this.get(field)) { | ||
this.compute(field, transformation, message); | ||
} | ||
return this; | ||
} | ||
validate(field, validator, message) { | ||
if (!validator(this.get(field), this)) { | ||
this.addError(field, message); | ||
} | ||
return this; | ||
} | ||
toJSON() { | ||
@@ -163,0 +182,0 @@ return { |
{ | ||
"name": "@flatfile/hooks", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
17528
548