Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema() macro for headless validation #34

Open
aldesantis opened this issue Aug 19, 2018 · 0 comments
Open

Schema() macro for headless validation #34

aldesantis opened this issue Aug 19, 2018 · 0 comments
Labels

Comments

@aldesantis
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant