Oh yeah! Absolutely. But that's when I'd split it based on functionality. Conditionals usually indicate that you're trying to force one thing to fulfill the role of many.
You can also invert the validation and have the parent be responsible (just like you mentioned).
On change, the input component would emit the change for the validateInput to run and the parent component will then let the input know if it's valid or not. :)
Log in to continue
We're a place where coders share, stay up-to-date and grow their careers.
Oh yeah! Absolutely. But that's when I'd split it based on functionality. Conditionals usually indicate that you're trying to force one thing to fulfill the role of many.
You can also invert the validation and have the parent be responsible (just like you mentioned).
In Angular, you could just do:
On change, the input component would emit the change for the
validateInput
to run and the parent component will then let the input know if it's valid or not. :)