Closed omkarmoghe closed 9 months ago
Hi @omkarmoghe! Currently, there isn't a way to register formats globally. You can pass the formats
option, but that only applies to a single schema: https://github.com/davishmcclurg/json_schemer/blob/da9c8f98255552a6b6b025bb43759cd15a2c00fd/README.md?plain=1#L183-L190
I think it's a great idea, though. I imagine we would want to provide global options for everything (not just formats
): https://github.com/davishmcclurg/json_schemer/blob/da9c8f98255552a6b6b025bb43759cd15a2c00fd/lib/json_schemer/schema.rb#L53-L69
Would you be open to a PR to enable something like this?
Definitely! Let me know if you want to work on it and I'll do my best help.
I imagine we would want to provide global options for everything (not just
formats
)
Agreed! I generally like this approach to making gems configurable: https://dev.to/vinistock/make-a-ruby-gem-configurable-228d
Basically a Configuration
singleton object that users can set default options via. Let me know if that approach looks good and I can take a stab at implementing it.
Basically a
Configuration
singleton object that users can set default options via. Let me know if that approach looks good and I can take a stab at implementing it.
:+1: that sounds good to me.
@omkarmoghe are you still interested in implementing this?
Hi @davishmcclurg, apologies for the delay, been a busy month/holiday season. I'm working on implementing this now! Should have a PR up this week 🤞🏽
Working in this branch: https://github.com/omkarmoghe/json_schemer/tree/default-config
Thanks again for the help, @omkarmoghe! I merged your changes and will release it shortly.
Was very interested in using the gem, was curious if there was a way to set or "register" formatters globally? Something similar to https://github.com/voxpupuli/json-schema#custom-format-validation. Would you be open to a PR to enable something like this?