1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 06:44:21 +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 =
useFormState<"OPEN" | "MANUAL" | undefined>(
resource?.value.access ?? undefined,
Validators.notEmpty,
Validators.mustBeDefined,
)
const slug =

View file

@ -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 =

View file

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