Experiencing a challenge with validations, I've created a Rails app (API only using ActiveRecord and Doorkeeper for protection) that successfully validates every request and returns errors in JSON format when a validation error occurs.
Currently, I am working on the client app (also a Rails app without a database or ActiveRecord) that interacts with the API. While I can display validation errors after form submission, the goal is to have client-side JavaScript validation before submitting the form, including checking for uniqueness in certain fields.
I may be overcomplicating things, but how should I tackle this? Should I utilize ActiveModel for basic validation checks? How can I check for uniqueness when the API can only be accessed through Doorkeeper? Would it be advisable to send an AJAX request from the client app for each field requiring unique validation to then make an API call to validate the field's uniqueness?
In your opinion, what would be the optimal solution?