Skip to content

Commit

Permalink
feat(de schema): use schema for max length for all text inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Nov 16, 2023
1 parent b874534 commit d297d38
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions src/pages/dataElements/form/createDataElementSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,65 @@ export const createDataElementSchema = (schemas: ModelSchemas) =>
name: z
.string()
.min(1, { message: requiredMessage })
.max(schemas.dataElement.properties.name.length || 255, {
.max(schemas.dataElement.properties.name.length as number, {
message: max50Message,
}),
})
.trim(),
shortName: z
.string()
.min(1, { message: requiredMessage })
.max(schemas.dataElement.properties.shortName.length || 255, {
.max(schemas.dataElement.properties.shortName.length as number, {
message: max50Message,
})
.trim(),
code: z
.string()
.max(schemas.dataElement.properties.code.length as number, {
message: max50Message,
}),
code: z.string().optional(),
})
.trim()
.optional(),
description: z
.string()
.max(255, {
.max(schemas.dataElement.properties.description.length as number, {
message: i18n.t(
'The value is to long. You can use up to 255 characters'
),
})
.trim()
.optional(),
formName: z
.string()
.max(schemas.dataElement.properties.formName.length as number, {
message: i18n.t(
'The value is to long. You can use up to 255 characters'
),
})
.trim()
.optional(),
url: z
.string()
.max(schemas.dataElement.properties.url.length as number, {
message: i18n.t(
'The value is to long. You can use up to 255 characters'
),
})
.trim()
.optional(),
fieldMask: z
.string()
.max(schemas.dataElement.properties.fieldMask.length as number, {
message: i18n.t(
'The value is to long. You can use up to 255 characters'
),
})
.trim()
.optional(),
url: z.string().optional(),
style: z.object({
color: z.string().optional(),
icon: z.string().optional(),
}),
icon: z.string().optional(),
fieldMask: z.string().optional(),
domainType: z.union([z.literal('AGGREGATE'), z.literal('TRACKER')]),
formName: z.string().optional(),
valueType: z
.union([
z.literal('TEXT'),
Expand Down

0 comments on commit d297d38

Please sign in to comment.