Assets, asset publishing

Just a question related to asset publishing.

Currently when using ActiveForm with client side validation, it will output the validation rules and error messages in the HTML.

How could we achieve the same thing if we want to build our frontend in a JS framework such as Vue or React? I know we can write our own custom validation in JS, but this means duplicating backend validation rules and error messages.

What techniques could we use to achieve the same result?

AJAX validation would, likely, do.

That’s something I’ve been wondering about as well. As @samdark mentioned, AJAX could be used, but it feels like we’ll be missing out too much on React/Vue client-side features by doing this, and doing a lot of roundtrips to the server that could be avoided.

What if we came up with a simple enough PHP/JS package that would expose the validations rules used server-side to our javascript. This would be fetched once from the client, and used to validate data locally. (Validation will of course still be happening on the server when saving.)

Still need to think this through…

1 Like

“What if we came up with a simple enough PHP/JS package that would expose the validations rules used server-side to our javascript. This would be fetched once from the client, and used to validate data locally.”

Exactly what one expects from a current web-framework.