This is the demo repository for the talk in RubyConf 2022 titled:
Never again without a contract: dry-validation
In order to make a close-to-real-life situation we will simulate a
new app having multiple services. Some of some these services would
have some parameters & payloads we will apply some basic enforcement
based on schemas (using Dry::Schema) or a contract (Dry::Validation).
-
business: This is place where we will host the most basic schemas & contracts via a gem, this gem will be used by the services and extended by them if needed.
-
api: The self-contained gem
Business::Apihaving a minimal set of endpoints which will be using the schemas & contracts exposed on business gem. -
web: The main web application exposing some endpoint, one of them, the
apiscope is actually theBusiness::Apigem.
TODO: Explain docker-compose
Build the container
docker-compose buildGet into the container & play around:
docker-compose run backend bashOnce you are inside the session, you can do most of the things
cd business
bundle exec rspecYou can also use the convenient Makefile:
docker-compose run backend makeor
docker-compose run backend make guardAfter checking out the repo, run bundle install to install dependencies. Then,
run rake spec to run the tests.
Bug reports and pull requests are welcome on GitHub at https://github.com/esparta/rubyconf2022. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The app is available as open source under the terms of the MIT License.
Everyone interacting in the Business project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.