Skip to content

Commit

Permalink
fix: change description max limit
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminic committed Dec 3, 2024
1 parent 5cd9efa commit c521cad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/components/form/fields/DescriptionField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18n from '@dhis2/d2-i18n'
import { TextAreaFieldFF } from '@dhis2/ui'
import { createMaxCharacterLength, TextAreaFieldFF } from '@dhis2/ui'
import React from 'react'
import { Field as FieldRFF } from 'react-final-form'
import { SchemaSection, useCheckMaxLengthFromSchema } from '../../../lib'

Check warning on line 5 in src/components/form/fields/DescriptionField.tsx

View workflow job for this annotation

GitHub Actions / lint

'useCheckMaxLengthFromSchema' is defined but never used
Expand All @@ -11,10 +11,7 @@ export function DescriptionField({
helpText?: string
schemaSection: SchemaSection
}) {
const validate = useCheckMaxLengthFromSchema(
schemaSection.name,
'description'
)
const validate = createMaxCharacterLength(2000)

return (
<FieldRFF
Expand Down
3 changes: 2 additions & 1 deletion src/pages/categories/form/categorySchema.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { z } from 'zod'
import { getDefaults, createFormValidate, modelFormSchemas } from '../../../lib'
import { Category } from '../../../types/generated'
import i18n from '@dhis2/d2-i18n'

Check failure on line 4 in src/pages/categories/form/categorySchema.ts

View workflow job for this annotation

GitHub Actions / lint

`@dhis2/d2-i18n` import should occur before import of `zod`

/* Note that this describes what we send to the server,
/* Note that this describes what we send to the server,
and not what is stored in the form. */
const { identifiable, referenceCollection, withAttributeValues } =
modelFormSchemas
Expand Down
14 changes: 3 additions & 11 deletions src/pages/organisationUnits/form/organisationUnitSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ export const organisationUnitSchema = identifiable
.extend({
shortName: z.string().trim().default(''),
code: z.string().trim().optional(),
description: z
.string()
.trim()
.max(2147483647, {
message: i18n.t('Should not exceed {{maxLength}} characters', {
maxLength: 2147483647,
}),
})
.optional(),
description: z.string().trim().optional(),
image: z.object({ id: z.string() }).optional(),
phoneNumber: z
.string()
Expand Down Expand Up @@ -50,9 +42,9 @@ export const organisationUnitSchema = identifiable
closedDate: z.string().date().optional(),
comment: z
.string()
.max(2147483647, {
.max(2000, {
message: i18n.t('Should not exceed {{maxLength}} characters', {
maxLength: 2147483647,
maxLength: 2000,
}),
})
.optional(),
Expand Down

0 comments on commit c521cad

Please sign in to comment.