1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: validation for variant payload number type (#4671)

Adds validation to number type for variants

---------

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
andreas-unleash 2023-09-13 10:23:39 +03:00 committed by GitHub
parent 4de8ea2553
commit 8b452084f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,7 +262,10 @@ export const VariantForm = ({
const validatePayload = (payload: IPayload) => {
if (!isValidPayload(payload)) {
setError(ErrorField.PAYLOAD, 'Invalid JSON.');
setError(
ErrorField.PAYLOAD,
payload.type === 'json' ? 'Invalid json' : 'Invalid number'
);
}
};
@ -293,7 +296,7 @@ export const VariantForm = ({
JSON.parse(payload.value);
}
if (variantTypeNumber && payload.type === 'number') {
Number(payload.value);
return !Number.isNaN(Number(payload.value));
}
return true;
} catch (e: unknown) {