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:
parent
4de8ea2553
commit
8b452084f3
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user