pragma
pragma copied to clipboard
Schema() macro for headless validation
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.