0

I am checking a value from an input text a form, the name of the input is

name="name['title']"

title, doing something like this:

if (!values.title) {
    errors.title = 'Required';
}

I have to do this for some other controls, so I thought I could make the control name dynamic, how can I achieve something like this?

let name = 'title';
if (!values.<name>) {
    errors.<name> = 'Required';
}

I updated the question to show how it is different from proposed solutions.

user3174311
  • 1,714
  • 5
  • 28
  • 66

0 Answers0