question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validating fields in slots

See original GitHub issue

Hi there!

What an excellent lib! There’s only one more hurdle to jump before the team adopts it.

When using a slot with an input for a field, I can’t seem to get the validator to recognize the updated model. Though the validator works on another field that’s generated by the lib. I don’t expect the field in the slot to output an error, but I would expect the validator to check the model based on the schema specifications so that valid === false.

Here’s a reproduction: https://codepen.io/joshhoegen/pen/jOMddvr

Despite being required and only accepting alpha chars, v-model="valid" isn’t updated based off of the model…

  • Is this the intended design?
  • Is there a recommended way I can ensure the form’s v-model returns false?

Thanks for the lib and all the insight you share!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
albanmcommented, Jan 19, 2021

Otherwise you have the right starting points. The solution would be something like that:

  • in validatable.js, process the error messages by running this.rules and filtering those that return a string, probably move the computed property rules in the same mixin for clarity
  • add the error messages to the slot params
  • add a showValidation param in the slot params that would probably be (this.validated || this.shouldValidate)
  • in computed property hasError manage 2 cases:
    • either there are children inputs then keep the current implementation
    • or check the length of error messages
  • in the slot params in on.change set this.shouldValidate to true

I think that would do the trick while maintaining compatibility with the rest of the code. But I also think that using v-input is more in line with the framework.

1reaction
joshhoegencommented, Jan 19, 2021

Cool! I see that in the first example, it works in an array. Couldn’t quite figure out how to with the plain string field, however I’m enamored with the “input” use case! ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Field - VeeValidate
Validates the field's current value and returns a promise that resolves with an object containing the error messages emitted by the various rule(s)....
Read more >
Validate Slot Values | Alexa Skills Kit - Amazon Developer
Slot validation lets you create validation rules for your slot values. Alexa can then check ... Under slot type field, select Validations.
Read more >
Validation with fields in slot - Get Help - Vue Forum
Hello, I use VeeValidate for form validation and it worked ok. But I decided to remake my editor using slot, ...
Read more >
validation inside slot not working correctly in 'eager' mode ...
There are two fields here: one inside the slot in the same file as the ValidationProvider (default slot content). The second has the...
Read more >
Validation of Custom Fields – Knowledge Base | RaiseNow
We are able to add custom fields but what about an opportunity to validate them. Let's try to implement a custom validation rule....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found