-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
It seems like there should be a smarter way of doing this...
def is_valid(loc, typ):
if (trial := toolz.dicttoolz.get_in(loc.split("/"), file, default=None)) is None:
raise ValidationError(f"{loc} key is missing.")
if not isinstance(trial, typ):
raise ValidationError(f"{loc} should be {typ_.__name__} is {type(trial).__name__}")
required = {
'name': str,
'version': dict,
('default_version', 'version/default_version'): str,
}
for valid, typ in required.items:
if isinstance(valid, tuple):
for tmp in valid:
with suppress(ValidationError):
is_valid(tmp, typ)
break
else:
raise ValidationError(...)
else:
is_valid(valid, typ)Or similar?
Originally posted by @oerc0122 in #19 (comment)
Various more elegant alternatives were considered. My current leaning is towards json-schema.
Metadata
Metadata
Assignees
Labels
No labels