Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore (indicator types list): add extra form validation #450

Merged
merged 15 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 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: 2024-11-25T10:03:10.019Z\n"
"PO-Revision-Date: 2024-11-25T10:03:10.019Z\n"
"POT-Creation-Date: 2024-11-27T08:30:38.416Z\n"
"PO-Revision-Date: 2024-11-27T08:30:38.417Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -891,6 +891,9 @@ msgstr "This field requires a unique value, please choose another one"
msgid "{{label}} (required)"
msgstr "{{label}} (required)"

msgid "Should not exceed {{maxLength}} characters"
msgstr "Should not exceed {{maxLength}} characters"

msgid "No changes to be saved"
msgstr "No changes to be saved"

Expand Down Expand Up @@ -1241,8 +1244,8 @@ msgstr ""
"Choose where this new organisation unit should be placed in the existing "
"hierarchy"

msgid "Set up the basic information for this organisation unit."
msgstr "Set up the basic information for this organisation unit."
msgid "Set up the basic information for this organisation unit"
msgstr "Set up the basic information for this organisation unit"

msgid "Opening date"
msgstr "Opening date"
Expand Down Expand Up @@ -1311,6 +1314,22 @@ msgstr ""
"This is the first organisation unit and will be created as the root of the "
"hierarchy."

msgid "Must be a valid mobile number"
msgstr "Must be a valid mobile number"

msgid "Must be a valid url"
msgstr "Must be a valid url"

msgid ""
"Longitude should be between -90 and 90. Latitude should be between -180 and "
"180"
msgstr ""
"Longitude should be between -90 and 90. Latitude should be between -180 and "
"180"

msgid "Parent organisation unit cannot be itself or a descendant of itself."
msgstr "Parent organisation unit cannot be itself or a descendant of itself."

msgid "No organisation units available"
msgstr "No organisation units available"

Expand Down
11 changes: 10 additions & 1 deletion src/pages/indicatorTypes/form/IndicatorTypesSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ import { getDefaults, createFormValidate, modelFormSchemas } from '../../../lib'
const { identifiable } = modelFormSchemas

export const IndicatorSchema = identifiable.extend({
factor: z.coerce.number().int(),
factor: z.coerce
.number({ invalid_type_error: 'Please enter a number' })
.int()
.max(
Number.MAX_SAFE_INTEGER,
`The number is too large. Please enter a valid integer.`
)
.refine((value) => value !== 0, {
message: 'Zero is not a valid value for factor',
}),
})

export const initialValues = getDefaults(IndicatorSchema)
Expand Down
Loading