fix/zero-padding (#10513)

* fix/zero-padding

* Check for NaN
This commit is contained in:
Shaurya Sharma 2024-07-31 09:43:27 +05:30 committed by GitHub
parent e371df916b
commit 10dba6f0ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,7 +15,7 @@ const {
} = require('superstruct');
import { validateMultilineCode } from '@/_helpers/utility';
import _ from 'lodash';
import _, { isNumber } from 'lodash';
import { reservedKeywordReplacer } from '@/_lib/reserved-keyword-replacer';
export const generateSchemaFromValidationDefinition = (definition, recursionDepth = 0) => {
@ -38,7 +38,7 @@ export const generateSchemaFromValidationDefinition = (definition, recursionDept
if (recursionDepth === 0) {
schema = coerce(schema, string(), (value) => {
const parsedValue = parseFloat(value);
const finalValue = parsedValue ? parsedValue : value;
const finalValue = isNumber(parsedValue) && Number.isFinite(parsedValue) ? parsedValue : value;
return finalValue;
});
}