Wiki: open source, Accord: A sane validation library for Scala
For agents: Markdown version · Wiki index · Explore
- Speaker: Tomer Gabel
- Event: Reversim Summit 2015
- Video: https://www.youtube.com/watch?v=AyjrAfLQfBw
- Transcript: /transcripts/2015/10-AyjrAfLQfBw.md
- Language: Hebrew · Type: ignite · Level: intermediate
- Topics: Software Engineering, Open Source, Functional Programming, Architecture
Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.
Summary
The speaker introduces Accord, an open-source validation library for Scala developed to address limitations in existing tools. The library provides a clean and simple Domain Specific Language (DSL) to define validation rules separately from domain objects. It aims to solve issues found in standard Java validation mechanisms and complex Scala type-class libraries by offering type-safe, composable, and readable validations. The audience learns about the design choices behind Accord, including its use of Scala macros for rule introspection and error description generation.
Key points
- 0:07 The speaker introduces the need for a data validation library in Scala, motivated by RPC domain object validation requirements.
- 1:25 Accord is presented as an open-source, Apache-licensed Scala validation library hosted on GitHub that returns success or a set of failures.
- 2:28 Java’s Bean Validation is criticized for polluting domain objects with annotations, being ugly in Scala, and lacking proper composition.
- 3:30 Accord uses a clean DSL for validation, whereas alternative Scala solutions like Scalaz Validation require complex category theory knowledge.
- 4:31 Scala macros are used in Accord for rule introspection and automatic generation of rule descriptions at compile time.
- 5:33 Accord is fully type-safe with no runtime dependencies, supports multiple Scala versions, and integrates with testing frameworks and Spring.
Takeaways
- Separate validation logic from domain objects to keep code clean and maintainable.
- Choose validation libraries that fit your team’s familiarity with functional programming concepts rather than overly complex type-class frameworks.
- Leverage Scala macros for compile-time introspection and automatic error description generation.
Questions this talk answers
- How does Accord compare to Java’s Bean Validation framework when used in Scala projects?
- Why does Accord use Scala macros for its validation implementation?
- How does Accord handle the composition of validation rules for collections and optional fields?
Technologies
Scala, Java, Spring
Tags
dsl, macros, open source, scala, software design, validation