voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.53k stars 242 forks source link

Docs unclear on reusing a validator #303

Open aviflax opened 8 years ago

aviflax commented 8 years ago

Hi, I’m new to Ruby so I apologize if this is otherwise obvious.

I’m implementing a Web API and I need it to validate request bodies. It will be validating the same kind of objects dozens of times a second, so I figured it would make sense to reuse a validator object, rather than call a class method repeatedly for validation. I perused the README and the API docs but I couldn’t figure it out.

I suspect this might be a common need, so it might be worthwhile adding this to the README. If someone could just reply here with a quick code snippet on how to do this, I’d be happy to open a PR for the README.

Thanks! Avi