in reply to Data Object Verification Modules?

An alternative to tobyink's Type::Tiny would be to use JSONSchema (also maintained by tobyink (!)). For a full-scale API it's a bit of work to set up, but very easy to maintain and very powerful. If your Dancer2 API accepts only JSON params it's the way to go in my experience.

See the tutorial examples.

(PS: There is an alternative, JSON::Validator, by one of the lead Mojo devs, but I have not used it.)

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Data Object Verification Modules?
by tobyink (Canon) on Jun 08, 2018 at 19:13 UTC

    Urgh. Replied to this earlier, but I guess I only got as far as the preview and then closed the tab or something. SSL errors in Chrome are making this site very annoying to use.

    Anyway, I probably wouldn't recommend JSON::Schema at the moment. It's based on a pretty old version of the JSON schema specification, and I don't plan on updating it until the specification stabilises. And when that does happen, JSON::Schema is likely to become a wrapper around JSON::Schema::AsType which is a frickin' awesome idea, and how I'd be implementing JSON Schema now if someone hadn't beaten me to it.

    Right now, JSON::Schema::AsType is a little inefficient in how it uses Type::Tiny, and could be made quite a bit faster. I plan on contributing some improvements in this area once the specification is more stable. It may already be faster than JSON::Schema though — I haven't benchmarked it.