# open source, Accord: A sane validation library for Scala

- Speaker: [Tomer Gabel](/wiki/speakers/tomer-gabel.md)
- Event: [Reversim Summit 2015](/wiki/years/2015.md)
- Video: https://www.youtube.com/watch?v=AyjrAfLQfBw
- Transcript: [/transcripts/2015/10-AyjrAfLQfBw.md](/transcripts/2015/10-AyjrAfLQfBw.md)
- Language: Hebrew · Type: ignite · Level: intermediate
- Topics: [Software Engineering](/wiki/topics/software-engineering.md), [Open Source](/wiki/topics/open-source.md), [Functional Programming](/wiki/topics/functional-programming.md), [Architecture](/wiki/topics/architecture.md)

> 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](https://www.youtube.com/watch?v=AyjrAfLQfBw&t=7s) The speaker introduces the need for a data validation library in Scala, motivated by RPC domain object validation requirements.
- [1:25](https://www.youtube.com/watch?v=AyjrAfLQfBw&t=85s) 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](https://www.youtube.com/watch?v=AyjrAfLQfBw&t=148s) Java's Bean Validation is criticized for polluting domain objects with annotations, being ugly in Scala, and lacking proper composition.
- [3:30](https://www.youtube.com/watch?v=AyjrAfLQfBw&t=210s) Accord uses a clean DSL for validation, whereas alternative Scala solutions like Scalaz Validation require complex category theory knowledge.
- [4:31](https://www.youtube.com/watch?v=AyjrAfLQfBw&t=271s) Scala macros are used in Accord for rule introspection and automatic generation of rule descriptions at compile time.
- [5:33](https://www.youtube.com/watch?v=AyjrAfLQfBw&t=333s) 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
