タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

restfulに関するkjirouuのブックマーク (1)

  • JavaScriptでバリデーションするときのAPI設計

    フォームのバリデーションを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設計
    kjirouu
    kjirouu 2018/04/18
    SPAではないサイト用のJS用のWeb APIを実装するときの論点が簡潔に列挙されている。あとは状況次第になりそう。
  • 1