forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix Select field preview (twentyhq#4507)
* fix: fix Select field preview Closes twentyhq#4084 * fix: fix field preview utils tests
- Loading branch information
1 parent
f02552b
commit 1925506
Showing
8 changed files
with
33 additions
and
17 deletions.
There are no files selected for viewing
7 changes: 4 additions & 3 deletions
7
...es/twenty-front/src/modules/object-record/record-field/types/guards/isFieldSelectValue.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { isString } from '@sniptt/guards'; | ||
|
||
import { FieldSelectValue } from '@/object-record/record-field/types/FieldMetadata'; | ||
import { selectFieldValueSchema } from '@/object-record/record-field/validation-schemas/selectFieldValueSchema'; | ||
|
||
export const isFieldSelectValue = ( | ||
fieldValue: unknown, | ||
): fieldValue is FieldSelectValue => isString(fieldValue); | ||
options?: string[], | ||
): fieldValue is FieldSelectValue => | ||
selectFieldValueSchema(options).safeParse(fieldValue).success; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...front/src/modules/object-record/record-field/validation-schemas/selectFieldValueSchema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from 'zod'; | ||
|
||
import { FieldSelectValue } from '@/object-record/record-field/types/FieldMetadata'; | ||
|
||
export const selectFieldValueSchema = ( | ||
options?: string[], | ||
): z.ZodType<FieldSelectValue> => | ||
options?.length | ||
? z.enum(options as [string, ...string[]]).nullable() | ||
: z.string().nullable(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters