From a9a1e9bc2163360a7942e8feeb4c8a9ff85db707 Mon Sep 17 00:00:00 2001 From: pianist <26953709+Pianist038801@users.noreply.github.com> Date: Mon, 20 Sep 2021 08:32:12 -0700 Subject: [PATCH] fix: ensure no leading or trailing whitespace on the string input (#206) Signed-off-by: Pianist038801 Co-authored-by: Pianist038801 --- src/components/Launch/LaunchForm/inputHelpers/string.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/Launch/LaunchForm/inputHelpers/string.ts b/src/components/Launch/LaunchForm/inputHelpers/string.ts index ec5c55b79..7bb2d8bd9 100644 --- a/src/components/Launch/LaunchForm/inputHelpers/string.ts +++ b/src/components/Launch/LaunchForm/inputHelpers/string.ts @@ -20,6 +20,12 @@ function validate({ value }: InputValidatorParams) { if (typeof value !== 'string') { throw new Error('Value is not a string'); } + if (value && value[0] === ' ') { + throw new Error('Value should not have a leading space'); + } + if (value && value[value.length - 1] === ' ') { + throw new Error('Value should not have a trailing space'); + } } export const stringHelper: InputHelper = {