フォームのバリデーションをJavaScriptでやりたい場合、どんなAPI設計にするのが良いか? 例 ユーザーのバリデーションが下記のように定義されているとする。 class User < ApplicationRecord validates :user_name, presence: true, uniqueness: true, format: { with: /\w/ } validates :age, numericality: { only_integer: true, greater_than_or_equal_to: 0 } end このバリデーションをどうにかJavaScript側からも使いたいけど、こういう場合はバリデーション用のAPIを毎回作る感じですかね? module Validations class UsersController < ::Applicatio
![JavaScriptでバリデーションするときのAPI設計](https://cdn-ak-scissors.b.st-hatena.com/image/square/d94595e65b12fd92f53f271a3aca74b0c8c4949c/height=288;version=1;width=512/https%3A%2F%2Fdiscourse.clean-rails.org%2Fimages%2Fdiscourse-logo-sketch-small.png)