A Swift framework designed to make validating Decodable input convenient, type safe, versitile, and efficient.
Most APIs and server-side rendered webpages deal with input from the outside world. Not all input is acceptable; some rules must be followed. And when they aren't we should be able to provide clear feedback on what rules were violated. When there is more than one thing wrong with the input we should report all violations instead of just halting at the first error we encounter.
This framework is inspired from working with
Validations. It is an attempt to address some of its pain points, which include:
Note: this framework is at a very early stage and much of the API is subject to change
By striving to fulfill the goals below, this framework aims to make writing good validations as painless as possible.
It consists of 3 targets: Decoded, Checked, and Validations. These incrementally provide the full functionality of this framework. But each can of course be used on its own.
Decoded: Capture success and error states from decoding
Decoded provides a layer on top of Swift's
Codable that allows for capturing and collecting error states.
Checked: Assert successful decoding and obtain a convenient view into the data
Checked provides convenient access to (a hierarchy of)
Decoded values and enables guaranteeing successful decoding.
ValidationsDescribe the conditions under which data is valid with
Validations aims to add a powerful domain specific language (DSL) to express what input we should consider valid.
|Last commit: 1 week ago|