- Most libraries do only validation. Schema does also coercion.
Pros:
- Schemas are represented using collections and maps etc.
- It's easy to modify existing schemas using general fns:
(s/defschema NewUser (dissoc User :_id))
- Provides coercion
- Coerce valus from strings to anything
- Useful when using with JSON
Cons:
- It's easy to lose propert order when schema is defined using
hash-map
- It's hard to validate a property if validation depends on value of another property
- Provides "machine-readable" errors, but the errors usually are lists, e.g.
(not (eq "123"))
it's a bit hard to read those using ClojureCould be fixed by implementing a library which implements some Protocol for each Schema- Schemas call
macros/validation-error
and create list describing the error