1. 8

Litmus is an Elixir library built at Lob for validating user input. We use it to validate API parameters are in the correct form. If you’ve ever used something like Joi in Javascript, Litmus is similar, albeit not as feature-rich yet.

  1. 2

    Awesome! This would’ve saved us a lot of annoyance at a past gig. :)

    Have y’all considered using modules or structs so we can maybe do typespecs on the schemas once they get past the validation?

    1. 1

      Can you do a comparison of litmus with ecto? Ecto does not need to be used with a database, and it has some validations built in, and it is very easy to create your own.

      It also looks like litmus only returns a single error at a time? Would it be possible to give all errors, so that we know how to fix everything in one go instead of continually doing validation just to uncover a single step at at time?

      1. 1

        I know we experimented early on with Ecto validation, but I can’t quite remember why we decided was wasn’t ideal for us. I know at the time Ecto was not yet at v3, and perhaps the validation facilities it has are better now? I know that we for sure wanted clear error messages, and validation as soon as possible in the request lifecyle, and those were motivators for building our own.

        That’s a good suggestion, and something we could definitely do in future versions. At the moment, Litmus is not-so-general as it was built specifically for our use case: we are validating user input in their API requests and we want to send back a single error message for the first thing wrong.