Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Dynamic Validation Vue Vee Validate

Hello i want to validate dynamic fields using vee validate, Fields having the same name. For Example

 
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


This looks like a clean approach to dynamically generating fields with Vee Validate. However, handling validation for fields with the same name might get tricky since Vee Validate uses name as the unique identifier for validation. You could try appending an index or key to the field names dynamically to ensure they are unique, like field.name + '_' + key. This should help Vee Validate distinguish between different instances of the same field type and display the correct error messages.

Also, as someone who loves generating creative content, this reminds me of a tool I recently used, the God Name Generator. It dynamically creates unique names with different themes, and it struck me how it’s similar to the way you’re dynamically handling these form fields. Maybe consider something like that for inspiration on structuring dynamic content cleanly.



I have attached (step 2) and the (horizontal) vue page, is there way to validate all the dynamic fields inside the step2, I feel like Yup Object is ignoring dynamic fields



Hi Syed,

I think "Form Generator" page describes how you can validate dynamically rendered fields. See

Regards,
Lauris Stepanovs,
Keenthemes Support Team















Hi Syed,

The name attribute value should be unique for each field.

You can use your key variable to make name value unique and then use the name for validation.

:name="`${field.name}-${key}`"

Regards, Lauris Stepanovs, Keenthemes Support Team

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(