1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 14:54:22 +00:00

🔧 Improve validators names

This commit is contained in:
Steffo 2021-10-14 18:08:00 +02:00 committed by Stefano Pigozzi
parent 0c528b0f7c
commit ae11406290
3 changed files with 5 additions and 4 deletions

View file

@ -55,7 +55,7 @@ export function GroupCreateBox({viewSet, resource}: GroupCreateBoxProps): JSX.El
const access = const access =
useFormState<"OPEN" | "MANUAL" | undefined>( useFormState<"OPEN" | "MANUAL" | undefined>(
resource?.value.access ?? undefined, resource?.value.access ?? undefined,
Validators.notEmpty, Validators.mustBeDefined,
) )
const slug = const slug =

View file

@ -32,7 +32,7 @@ export function ProjectCreateBox({viewSet, resource}: ProjectCreateBoxProps): JS
const visibility = const visibility =
useFormState<"PUBLIC" | "INTERNAL" | "PRIVATE" | undefined>( useFormState<"PUBLIC" | "INTERNAL" | "PRIVATE" | undefined>(
resource?.value.visibility ?? undefined, resource?.value.visibility ?? undefined,
Validators.notEmpty, Validators.mustBeDefined,
) )
const slug = const slug =

View file

@ -10,14 +10,14 @@ export class Validators {
return true return true
} }
static notEmpty<T>(val: T): Validity { static mustBeDefined<T>(val: T): Validity {
if(!val) { if(!val) {
return undefined return undefined
} }
return true return true
} }
static notZeroLength<T extends { length: number }>(val: T): Validity { static mustContainElements<T extends { length: number }>(val: T): Validity {
if(!val) { if(!val) {
return undefined return undefined
} }
@ -27,3 +27,4 @@ export class Validators {
return true return true
} }
} }