-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: validation for variant payload number type #4671
Conversation
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@@ -293,7 +293,7 @@ export const VariantForm = ({ | |||
JSON.parse(payload.value); | |||
} | |||
if (variantTypeNumber && payload.type === 'number') { | |||
Number(payload.value); | |||
return !isNaN(Number(payload.value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it shouldn't matter here but in general it's safer to use Number.isNaN over global isNaN
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally if I was touching a component without a test I'd add one to test the new stuff I added
@@ -262,7 +262,7 @@ export const VariantForm = ({ | |||
|
|||
const validatePayload = (payload: IPayload) => { | |||
if (!isValidPayload(payload)) { | |||
setError(ErrorField.PAYLOAD, 'Invalid JSON.'); | |||
setError(ErrorField.PAYLOAD, 'Invalid value.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the payload.type to specify "Invalid JSON" or "Invalid Number"
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
Adds validation to number type for variants