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:
parent
0c528b0f7c
commit
ae11406290
3 changed files with 5 additions and 4 deletions
|
@ -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 =
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue