15 ms·
This is what I'm using for schema validation in FormAPI [1]. The best part about using a standard is that there's a lot of open source libraries you can use. It
by nathan_f77 9y ago
This is what I'm using for schema validation in FormAPI [1]. The best part about using a standard is that there's a lot of open source libraries you can use. It's really easy to validate a schema in Ruby [2]. I use json-schema-faker [3] to fill out PDFs with test data. I also use AlpacaJS [4] to generate HTML forms based on the JSON schema.
Anyway, I'm really glad I didn't try to roll my own thing for schema validation. Alpaca is insanely powerful, and it would have taken me weeks or months to build the online forms from scratch.
[1] http://formapi.io http://formapi.io
[2] https://github.com/ruby-json-schema/json-schema https://github.com/ruby-json-schema/json-schema
[3] https://github.com/json-schema-faker/json-schema-faker https://github.com/json-schema-faker/json-schema-faker
[4] http://www.alpacajs.org/ http://www.alpacajs.org/
- tappleby 9y agoWe have a similar setup for extending our app with custom fields / forms using ruby-json-schema and react-jsonschema-form [1]. ruby-json-schema has worked out quite well, we added a custom schema reader so that we could generate enums dynamically based on records in the database via custom refs eg. app://schemas/organizations?type_eq=education&tags=one, any of these internal refs are inlined at the API layer. One issue we did run into with ruby-json-schema, is the schema caching is not thread safe. We opted to clear the cache after each validation, this ended up causing race-condition issues. In the end we had to use a mutex on write and cache the validation result (not ideal, but our app isn't that write heavy). [1] https://github.com/mozilla-services/react-jsonschema-form https://github.com/mozilla-services/react-jsonschema-form