Conversation
Hey @misja Thanks for your PR, I appreciate it! I like the idea of having a Eventually, I think there should be a Aside from that, the PR looks good to me! |
Hi @jasonwalsh , thanks for the review! I must admit this pull request was also to test the waters and see if the project was still active/being watched, glad it is :) I agree with dropping class Format(Component, str):
def accept(self, visitor, *args):
try:
if self != '':
return visitor.visit_format(self, *args)
except AttributeError:
pass Any visitor implementing the method could then use its value for a check - {
'email': lambda instance: re.match('email regex', instance) is not None,
'date-time': ...
}[primitive](instance) Anyway, let me know your thoughts. And again, really like this project, I'll see what else I can do if time permits. |
Hey @misja I like the idea of having a separate class for Also, in reading the documentation, it states: Implementations MAY support the "format" keyword as a validation assertion. Should they choose to do so:
Maybe in the class Format(str):
def __new__(cls, value, *args, **kwargs):
return super().__new__(cls, value)
def __init__(self, value, validate=False):
self.validate = validate
def accept(self, visitor, *args):
if self:
visitor.visit_format(self, *args) And maybe in the command line API, there's a flag like Let me know what you think, and thanks again for your interest in the project! |
We should be careful or this could end up in a very long thread about spec semantics :) Looking again at my suggestion and your comments (thanks!) I think it would be better to keep a strict separation of concerns. The So I think any configuration should stay limited to the Another reason to keep the configuration limited to the validating visitor is because it would make no sense in a transforming visitor e.g. when creating Avro or Thrift schemas where the Will try to find some time to add commits to this pull pursuing the mixin approach so that we have some code to talk about. And perhaps some more along the way, I ran the JSON Schema test suite and err, quite a bit of work still to be done ;) |
Hey @misja Thanks for your comment, that makes sense to me. I like the idea of implementing a mixin class for
Yes, I totally agree with this. Thanks again! |
I really like the parsing approach this projects takes and whilst trying things I was missing some keywords. This pull adds the
format
keyword to primitives plus two additional string type keywordscontentEncoding
andcontentMediaType
which were recently added. As for theformat
keyword, this doesn't require an implementation, I've added it in a way that it can be implemented by subclassing the validator.