Skip to content

Comments

fix(renderer): Remove redundant indexing logic from data type validation#1565

Merged
Hyperkid123 merged 1 commit intodata-driven-forms:masterfrom
asirvadAbrahamVarghese:fix-renderer-validator-helper
Feb 16, 2026
Merged

fix(renderer): Remove redundant indexing logic from data type validation#1565
Hyperkid123 merged 1 commit intodata-driven-forms:masterfrom
asirvadAbrahamVarghese:fix-renderer-validator-helper

Conversation

@asirvadAbrahamVarghese
Copy link
Contributor

Fixes #(issue) (if applicable)

Description
App throws a runtime error while rendering a field with a schema that contains dataType property

image

Please include a summary of the change.

dataTypeValidator already performs the indexing and returns the required validator factory function.

getValidate redundantly attempts to access the factory via indexing again(see) - dataTypeValidator(dataType)[dataType]().
Since the value returned by dataTypeValidator is already the resolved factory, this second indexing operation evaluates to undefined, leading to a runtime crash

Removing the redundant second indexing resolves the issue:
image

Schema (if applicable)

const schema = {
  title: 'Testing dialog',
  description: 'Description of testing Dialog',
  fields: [
    {
      name: 'text_box_8',
      label: 'Text Box integer value',
      title: 'Text Box integer value',
      dataType: 'integer',
      component: componentTypes.TEXT_FIELD,
      type: 'number',
    },
    {
      name: 'text_box_9',
      label: 'Text Box string value',
      title: 'Text Box string value',
      dataType: 'string',
      component: componentTypes.TEXT_FIELD,
    },
  ],
};

Checklist: (please see documentation page for more information)

  • Yarn build passes
  • Yarn lint passes
  • Yarn test passes
  • Test coverage for new code (if applicable)
  • Documentation update (if applicable)
  • Correct commit message
    • format fix|feat({scope}): {description}
    • i.e. fix(pf3): wizard correctly handles next button
    • fix will release a new _._.X version
    • feat will release a new _.X._ version (use when you introduce new features)
      • we want to avoid any breaking changes, please contact us, if there is no way how to avoid them
    • scope: package
    • if you update the documentation or tests, do not use this format
      • i.e. Fix button on documenation example page

@vercel
Copy link

vercel bot commented Feb 16, 2026

@asirvadAbrahamVarghese is attempting to deploy a commit to the data-driven-forms Team on Vercel.

A member of the Team first needs to authorize it.

return [
...(validate ? validate.map((validator) => prepareValidator(validator, convertedMapper)) : []),
...(dataType ? [dataTypeValidator(dataType)[dataType]()] : []),
...(dataType ? [dataTypeValidator(dataType)() as unknown as ValidatorFunction] : []),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I can’t eliminate the type mismatch, I’m first casting the value to unknown and then explicitly typing it as ValidatorFunction

@Hyperkid123 Hyperkid123 merged commit 352fd8a into data-driven-forms:master Feb 16, 2026
1 of 2 checks passed
@Hyperkid123
Copy link
Member

Thank you @asirvadAbrahamVarghese for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants