Skip to content

Commit

Permalink
fix(de name shortname inputs): validate max length (50 chars)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Oct 30, 2023
1 parent d2b518f commit 4473cef
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 45 deletions.
89 changes: 46 additions & 43 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-10-16T12:26:20.848Z\n"
"PO-Revision-Date: 2023-10-16T12:26:20.848Z\n"
"POT-Creation-Date: 2023-10-26T12:50:29.542Z\n"
"PO-Revision-Date: 2023-10-26T12:50:29.542Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -561,6 +561,40 @@ msgstr "Basic information"
msgid "Set up the information for this data element"
msgstr "Set up the information for this data element"

msgid "Disaggregation and Option sets"
msgstr "Disaggregation and Option sets"

msgid "Set up disaggregation and predefined options."
msgstr "Set up disaggregation and predefined options."

msgid "LegendSet"
msgstr "LegendSet"

msgid ""
"Visualize values for this data element in Analytics app. Multiple legendSet "
"can be applied."
msgstr ""
"Visualize values for this data element in Analytics app. Multiple legendSet "
"can be applied."

msgid "Aggregation levels"
msgstr "Aggregation levels"

msgid "Custom attributes"
msgstr "Custom attributes"

msgid "Custom fields for your DHIS2 instance"
msgstr "Custom fields for your DHIS2 instance"

msgid "Required"
msgstr "Required"

msgid "Cannot be longer than {{number}} character"
msgstr "Cannot be longer than {{number}} character"

msgid "The value is to long. You can use up to 255 characters"
msgstr "The value is to long. You can use up to 255 characters"

msgid "{{fieldLabel}} (required)"
msgstr "{{fieldLabel}} (required)"

Expand Down Expand Up @@ -588,6 +622,16 @@ msgstr "Url"
msgid "A web link that provides extra information"
msgstr "A web link that provides extra information"

msgid "Color and icon"
msgstr "Color and icon"

msgid ""
"A color and icon are helpful for identifying data elements in "
"information-dense screens."
msgstr ""
"A color and icon are helpful for identifying data elements in "
"information-dense screens."

msgid "Field mask"
msgstr "Field mask"

Expand All @@ -606,41 +650,6 @@ msgstr "An alternative name used in section or automatic data entry forms."
msgid "Store zero data values"
msgstr "Store zero data values"

msgid "Disaggregation and Option sets"
msgstr "Disaggregation and Option sets"

msgid "Set up disaggregation and predefined options."
msgstr "Set up disaggregation and predefined options."

msgid "LegendSet"
msgstr "LegendSet"

msgid ""
"Visualize values for this data element in Analytics app. Multiple legendSet "
"can be applied."
msgstr ""
"Visualize values for this data element in Analytics app. Multiple legendSet "
"can be applied."

msgid "Aggregation levels"
msgstr "Aggregation levels"

msgid "Custom attributes"
msgstr "Custom attributes"

msgid "Custom fields for your DHIS2 instance"
msgstr "Custom fields for your DHIS2 instance"

msgid "Color and icon"
msgstr "Color and icon"

msgid ""
"A color and icon are helpful for identifying data elements in "
"information-dense screens."
msgstr ""
"A color and icon are helpful for identifying data elements in "
"information-dense screens."

msgid "A data element can either be aggregated or tracked data."
msgstr "A data element can either be aggregated or tracked data."

Expand Down Expand Up @@ -677,12 +686,6 @@ msgstr "Option set comment"
msgid "Choose a set of predefined comment for data entry"
msgstr "Choose a set of predefined comment for data entry"

msgid "Required"
msgstr "Required"

msgid "The value is to long. You can use up to 255 characters"
msgstr "The value is to long. You can use up to 255 characters"

msgid "Metadata management"
msgstr "Metadata management"

Expand Down
13 changes: 11 additions & 2 deletions src/pages/dataElements/form/dataElementSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ import i18n from '@dhis2/d2-i18n'
import { z } from 'zod'

const requiredMessage = i18n.t('Required')
const max50Message = i18n.t('Cannot be longer than {{number}} character', {
number: 50,
})

export const dataElementSchema = z.object({
name: z.string().min(1, { message: requiredMessage }),
shortName: z.string().min(1, { message: requiredMessage }),
name: z
.string()
.min(1, { message: requiredMessage })
.max(50, { message: max50Message }),
shortName: z
.string()
.min(1, { message: requiredMessage })
.max(50, { message: max50Message }),
code: z.string().optional(),
description: z
.string()
Expand Down

0 comments on commit 4473cef

Please sign in to comment.