@byll/validated
Advanced tools
Comparing version 1.9.2 to 1.9.3
@@ -15,3 +15,3 @@ "use strict"; | ||
} | ||
if (precision !== undefined && scale !== undefined) { | ||
if (precision !== undefined && scale !== undefined && !decimal.eq(0)) { | ||
// Do not allow because that's not supported by postgres | ||
@@ -18,0 +18,0 @@ if (scale > precision) { |
{ | ||
"name": "@byll/validated", | ||
"version": "1.9.2", | ||
"version": "1.9.3", | ||
"main": "lib/src/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "lib/src/index", |
@@ -13,3 +13,3 @@ import { Decimal } from 'decimal.js-light' | ||
if (precision !== undefined && scale !== undefined) { | ||
if (precision !== undefined && scale !== undefined && !decimal.eq(0)) { | ||
// Do not allow because that's not supported by postgres | ||
@@ -16,0 +16,0 @@ if (scale > precision) { throw new Error('Precision must be >= scale') } |
@@ -10,3 +10,12 @@ import { expect } from 'chai' | ||
expect(isValidDecimalString('0.012', 2, 2)).to.equal(false) | ||
expect(isValidDecimalString('0', 6, 6)).to.equal(true) | ||
expect(isValidDecimalString('0.1', 6, 6)).to.equal(true) | ||
expect(isValidDecimalString('0.132353', 6, 6)).to.equal(true) | ||
expect(isValidDecimalString('0.1323530', 6, 6)).to.equal(true) | ||
expect(isValidDecimalString('0.1323533', 6, 6)).to.equal(false) | ||
expect(isValidDecimalString('1', 6, 6)).to.equal(false) | ||
expect(isValidDecimalString('10.125213', 6, 6)).to.equal(false) | ||
expect(isValidDecimalString('10.1', 6, 6)).to.equal(false) | ||
expect(isValidDecimalString('10', 6, 6)).to.equal(false) | ||
}) | ||
}) |
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
97038
1116