@dynamatix/gb-schemas 1.2.46 → 1.2.48
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.
|
@@ -17,8 +17,8 @@ class Pound extends mongoose.SchemaType {
|
|
|
17
17
|
if (typeof val !== 'string') {
|
|
18
18
|
throw new mongoose.Error.CastError('Pound', val, this.path, new Error('Pound value must be a string or number'));
|
|
19
19
|
}
|
|
20
|
-
// Remove
|
|
21
|
-
|
|
20
|
+
// Remove commas for numeric validation
|
|
21
|
+
const cleaned = val.replace(/,/g, '');
|
|
22
22
|
// Check if the cleaned value is a valid number
|
|
23
23
|
if (isNaN(Number(cleaned))) {
|
|
24
24
|
throw new mongoose.Error.CastError('Pound', val, this.path, new Error(`${val} is not a valid currency value`));
|
|
@@ -31,8 +31,8 @@ class Pound extends mongoose.SchemaType {
|
|
|
31
31
|
minimumFractionDigits: 2,
|
|
32
32
|
maximumFractionDigits: 2
|
|
33
33
|
});
|
|
34
|
-
//
|
|
35
|
-
return
|
|
34
|
+
// Return without symbol prefixed
|
|
35
|
+
return `${formattedValue}`;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
// Register the custom type globally with Mongoose
|