Where should simple validations happen?

I’m wondering what current opinions are as to what part of the app should handle simple validations. As an example, think of a todo app that has an input field. The user should not be able to submit an empty string.

I’m not asking how to validate, but where in an ember app with no defined controllers validations belong (and why).

On one hand, it seems to make sense to recognize that the input is blank and stop it right there at the component level, capturing the action before submitting sending the action to the route. On the other hand, it seems like an attribute on a record (a todo record in this case) should be the concern of the model itself and therefore should be checked at the route level before submitting it to the server.

While it’s also possible to hand it all off to the server and let your backend handle validations, a trip across the wire in this case seems silly.

Would love to hear different opinions and reasoning for where this type of validation logic belongs.

1 Like

My forms are components and so I validate on component file and when everything is good I use sendAction to forward data to the route. Unfortunately I still struggling with presenting server side errors so with that I don’t have any answer yet

I was definitely leaning toward validating in the component since that seems more in line with the way controllers were used to handle validations, just wanted to hear other people’s thoughts or reasoning for why it makes more sense to do one versus another.

Thanks for your reply!