-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate user header #167
Validate user header #167
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I've left a couple of small comments, but nothing important.
csvy/validators.py
Outdated
if key in VALIDATORS_REGISTRY: | ||
if not isinstance(value_, dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this, I suppose any Mapping
type would work, not just dict
s. The same is true for the input argument.
That said, users probably aren't going to be using other types of Mapping
here all that often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And would TypeError
maybe be more appropriate than ValueError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes to the second - I'll update. About the first, anything that can be unpacked with **
would work. I was not sure if Mapping
s in general allow this, so I sticked to dict
that I know will work and, as you say, it is what most people will use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 08e187c
Replaces the
validate_read
andvalidate_write
withvalidate_header
andheader_to_dict
, respectively.validate_header
is used in just after reading) and just before writing operations to ensure that the header always complies with any registered validator.header_to_dict
is run just before a write operation aftervalidate_header
to ensure that the header is serializable.A couple of extra checks have been added to ensure the robustness of the process.