@punks/backend-entity-manager 0.0.496 → 0.0.498
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntryValidationResult } from "../abstractions/serializer";
|
|
2
2
|
export declare const fieldRequiredValidator: <TSheetItem>(item: TSheetItem, selector: (item: TSheetItem) => any) => EntryValidationResult;
|
|
3
|
-
export declare const fieldNumericValidator: <TSheetItem>(item: TSheetItem, selector: (item: TSheetItem) => number, params
|
|
3
|
+
export declare const fieldNumericValidator: <TSheetItem>(item: TSheetItem, selector: (item: TSheetItem) => number, params?: {
|
|
4
4
|
min?: number;
|
|
5
5
|
max?: number;
|
|
6
6
|
}) => EntryValidationResult;
|
package/dist/esm/index.js
CHANGED
|
@@ -41151,16 +41151,16 @@ const fieldNumericValidator = (item, selector, params) => {
|
|
|
41151
41151
|
const value = selector(item);
|
|
41152
41152
|
const isInvalid = value && !isNaN(value);
|
|
41153
41153
|
const errors = [];
|
|
41154
|
-
if (value && isNaN(value)) {
|
|
41154
|
+
if (!!value && !isNaN(value)) {
|
|
41155
41155
|
errors.push({ errorCode: "notNumeric" });
|
|
41156
41156
|
}
|
|
41157
|
-
if (!!params
|
|
41157
|
+
if (!!params?.min && !!value && value < params.min) {
|
|
41158
41158
|
errors.push({
|
|
41159
41159
|
errorCode: "min",
|
|
41160
41160
|
payload: { current: value, expected: params.min },
|
|
41161
41161
|
});
|
|
41162
41162
|
}
|
|
41163
|
-
if (!!params
|
|
41163
|
+
if (!!params?.max && !!value && value > params.max) {
|
|
41164
41164
|
errors.push({
|
|
41165
41165
|
errorCode: "max",
|
|
41166
41166
|
payload: { current: value, expected: params.max },
|