pragma icon indicating copy to clipboard operation
pragma copied to clipboard

Schema() macro for headless validation

Open aldesantis opened this issue 7 years ago • 0 comments

https://github.com/pragmarb/pragma/wiki/Validating-query-parameters

If we implemented a Schema() macro in all operations that checks whether a schema.default skill is present and runs validations, query parameter validation could be simplified as follows:

module API
  module V1
    module Article
      module Operation
        class Index < Pragma::Operation::Index
          self['schema.default'] = Dry::Validation.Schema do
            optional(:user_id).maybe(:int?)
          end
        end
      end
    end
  end
end

This would also be very useful for headless operations, since they wouldn't require a model anymore.

aldesantis avatar Aug 19 '18 13:08 aldesantis