1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【解決】sinatra-validationの書式が変わってて苦労したメモ

Posted at

問題

少し前に作ったsinatraアプリを流用したら、validationでエラー発生。

結論

dry-validation のバージョンが変わって、書式が変わっていた模様

流用元のコード

post '/hoge' do
    validates {
        required(:fuga).filled(:string).format?(DATE_FORMAT)
    }
    ...
    200
end

修正後のコード

post '/hoge' do
    validates{
        params{
            required(:fuga).filled(:string, format?: DATE_FORMAT)
        }
    }
    ...
    200
end

その他

  • sinatra-validationはdry-rbの中のdry-validationを使いやすくしてくれているもの、らしい
    • sinatra-validation
      • ↑のサンプルがちょっと古い模様
    • dry-rb
      • 色々揃いすぎてて把握するのが大変
    • dry-validation
      • ここのドキュメントも掘り進めるのは大変
  • dry-validationのソースコードも見たけど、格調高くてワタシには読み解けず。。
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?