Skip to content

Error message shown on review page when optional middle name is left empty #10840

@oni-on1003

Description

@oni-on1003

Describe the bug
We have an optional middle name field. If this field has no value, the review page displays an error.

Which feature of OpenCRVS your bug concern?
Declaration form configuration

To Reproduce
Steps to reproduce the behaviour:

  1. Create a name field similar to the code below
{
      id: 'child.name',
      type: FieldType.NAME,
      required: true,
      configuration: {
        maxLength: MAX_NAME_LENGTH,
        name: {
          firstname: {
            required: true
          },
          middlename: {
            required: false
          },
          surname: {
            required: true
          }
        }
      },
      hideLabel: true,
      label: {
        defaultMessage: "Child's name",
        description: 'This is the label for the field',
        id: 'event.birth.action.declare.form.section.child.field.name.label'
      },
      validation: [ invalidNameValidator('child.name')]
    },
  1. Update the invalidNameValidator validator and add this line inside the validator property
    middlename: field('middlename').isValidEnglishName(),
  2. Create a declaration and check the review page

Expected behaviour
The validator should not be triggered if the middle name field is empty.

Country Configuration Version:
v1.9.0-beta-3

Screencast.from.2025-10-22.15-47-54.mp4

Metadata

Metadata

Assignees

Labels

IET requestissues that came up from IET triage

Type

Projects

Status

Completed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions