[Ruby] [Solved] The memo of the sinatra-validation format has changed

less than 1 minute read

Problem

If I use the sinatra app I made a while ago, an error occurs in validation.

Conclusion

The format of dry-validation has changed and the format seems to have changed.

Source code

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

Modified code

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

Other

  • It seems that sinatra-validation makes dry-validation in dry-rb easy to use.
    • sinatra-validation
      • The sample of ↑ seems to be a little old
    • dry-rb
      • It’s difficult to understand because there are too many items
    • dry-validation
      • It is difficult to dig through the documents here
  • I also looked at the source code of dry-validation, but I could not understand it because it was so high. ..