Skip to content

Commit 7f2fbba

Browse files
committed
fix: accept number type in setFieldValue method for better input handling
1 parent dc29e73 commit 7f2fbba

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adminforth/dataConnectors/baseConnector.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
271271
}
272272
throw new Error(`Value is not a decimal. Field ${field.name} with type is ${field.type}, but got value: ${value} with type ${typeof value}`);
273273
}
274+
// Accept number
275+
if (typeof value === "number") {
276+
if (Number.isFinite(value)) {
277+
return this.setFieldValue(field, value.toString());
278+
}
279+
throw new Error(`Value is not a decimal. Field ${field.name} with type is ${field.type}, but got value: ${value} with type ${typeof value}`);
280+
}
274281
// Accept Decimal-like objects (e.g., decimal.js) by using toString()
275282
if (value && typeof value === "object" && typeof (value as any).toString === "function") {
276283
const s = (value as any).toString();

0 commit comments

Comments
 (0)