From ae11406290fced8b4f65d68b09497596151b5041 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 14 Oct 2021 18:08:00 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Improve=20validators=20names?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/group/GroupCreateBox.tsx | 2 +- frontend/src/components/project/ProjectCreateBox.tsx | 2 +- frontend/src/utils/Validators.ts | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/group/GroupCreateBox.tsx b/frontend/src/components/group/GroupCreateBox.tsx index 52cbfed..bc29a53 100644 --- a/frontend/src/components/group/GroupCreateBox.tsx +++ b/frontend/src/components/group/GroupCreateBox.tsx @@ -55,7 +55,7 @@ export function GroupCreateBox({viewSet, resource}: GroupCreateBoxProps): JSX.El const access = useFormState<"OPEN" | "MANUAL" | undefined>( resource?.value.access ?? undefined, - Validators.notEmpty, + Validators.mustBeDefined, ) const slug = diff --git a/frontend/src/components/project/ProjectCreateBox.tsx b/frontend/src/components/project/ProjectCreateBox.tsx index de935d8..c45661f 100644 --- a/frontend/src/components/project/ProjectCreateBox.tsx +++ b/frontend/src/components/project/ProjectCreateBox.tsx @@ -32,7 +32,7 @@ export function ProjectCreateBox({viewSet, resource}: ProjectCreateBoxProps): JS const visibility = useFormState<"PUBLIC" | "INTERNAL" | "PRIVATE" | undefined>( resource?.value.visibility ?? undefined, - Validators.notEmpty, + Validators.mustBeDefined, ) const slug = diff --git a/frontend/src/utils/Validators.ts b/frontend/src/utils/Validators.ts index 866d828..e086838 100644 --- a/frontend/src/utils/Validators.ts +++ b/frontend/src/utils/Validators.ts @@ -10,14 +10,14 @@ export class Validators { return true } - static notEmpty(val: T): Validity { + static mustBeDefined(val: T): Validity { if(!val) { return undefined } return true } - static notZeroLength(val: T): Validity { + static mustContainElements(val: T): Validity { if(!val) { return undefined } @@ -27,3 +27,4 @@ export class Validators { return true } } +