@flatfile/hooks
Advanced tools
Comparing version 1.5.1 to 1.6.0
@@ -89,2 +89,19 @@ type TPrimitive = string | boolean | number | null; | ||
get(field: string): null | TRecordValue; | ||
/** | ||
* Returns an array of the error-level messages for the record | ||
* @param fields - Optional field or array of fields to filter errors by | ||
* @returns Array of error messages with level 'error' | ||
* @example | ||
* ```typescript | ||
* // Get all errors | ||
* const allErrors = record.getErrors(); | ||
* | ||
* // Get errors for specific field | ||
* const nameErrors = record.getErrors('name'); | ||
* | ||
* // Get errors for multiple fields | ||
* const errors = record.getErrors(['name', 'age']); | ||
* ``` | ||
*/ | ||
getErrors(fields?: keyof M | (keyof M)[]): IRecordInfo<M>[]; | ||
getMetadata(): Object; | ||
@@ -91,0 +108,0 @@ getLinks(field: string): TRecordData<TPrimitive>[] | null; |
@@ -168,2 +168,27 @@ "use strict"; | ||
} | ||
/** | ||
* Returns an array of the error-level messages for the record | ||
* @param fields - Optional field or array of fields to filter errors by | ||
* @returns Array of error messages with level 'error' | ||
* @example | ||
* ```typescript | ||
* // Get all errors | ||
* const allErrors = record.getErrors(); | ||
* | ||
* // Get errors for specific field | ||
* const nameErrors = record.getErrors('name'); | ||
* | ||
* // Get errors for multiple fields | ||
* const errors = record.getErrors(['name', 'age']); | ||
* ``` | ||
*/ | ||
getErrors(fields) { | ||
if (fields) { | ||
const fieldsArray = Array.isArray(fields) ? fields : [fields].filter(Boolean); | ||
return this._info.filter( | ||
(info) => info.level === "error" && fieldsArray.includes(info.field) | ||
); | ||
} | ||
return this._info.filter((info) => info.level === "error"); | ||
} | ||
getMetadata() { | ||
@@ -170,0 +195,0 @@ return this.metadata; |
{ | ||
"name": "@flatfile/hooks", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
26280
783