hdmf.validate.validator module
- hdmf.validate.validator.check_type(expected, received, string_format=None)
expected should come from the spec received should come from the data
- hdmf.validate.validator.get_iso8601_regex()
- hdmf.validate.validator.get_string_format(data)
Return the string format of the given data. Possible outputs are “isodatetime” and None.
- hdmf.validate.validator.get_type(data, builder_dtype=None)
Return a tuple of (the string representation of the type, the format of the string data) for the given data.
- hdmf.validate.validator.check_shape(expected, received)
- class hdmf.validate.validator.ValidatorMap(namespace)
Bases:
object
A class for keeping track of Validator objects for all data types in a namespace
- Parameters:
namespace (
SpecNamespace
) – the namespace to builder map for
- property namespace
- valid_types(spec)
Get all valid types for a given data type
- get_validator(data_type)
Return the validator for a given data type
- Parameters:
data_type (
BaseStorageSpec
orstr
) – the data type to get the validator for
- validate(builder)
Validate a builder against a Spec
builder
must have the attribute used to specifying data type by the namespace used to construct this ValidatorMap.- Parameters:
builder (
BaseBuilder
) – the builder to validate- Returns:
a list of errors found
- Return type:
- class hdmf.validate.validator.Validator(spec, validator_map)
Bases:
object
A base class for classes that will be used to validate against Spec subclasses
- Parameters:
spec (
Spec
) – the specification to use to validatevalidator_map (
ValidatorMap
) – the ValidatorMap to use during validation
- property spec
- property vmap
- abstract validate(value)
- Parameters:
value (None) – either in the form of a value or a Builder
- Returns:
a list of Errors
- Return type:
- classmethod get_spec_loc(spec)
- classmethod get_builder_loc(builder)
- class hdmf.validate.validator.AttributeValidator(spec, validator_map)
Bases:
Validator
A class for validating values against AttributeSpecs
- Parameters:
spec (
AttributeSpec
) – the specification to use to validatevalidator_map (
ValidatorMap
) – the ValidatorMap to use during validation
- class hdmf.validate.validator.BaseStorageValidator(spec, validator_map)
Bases:
Validator
A base class for validating against Spec objects that have attributes i.e. BaseStorageSpec
- Parameters:
spec (
BaseStorageSpec
) – the specification to use to validatevalidator_map (
ValidatorMap
) – the ValidatorMap to use during validation
- validate(builder)
- Parameters:
builder (
BaseBuilder
) – the builder to validate- Returns:
a list of Errors
- Return type:
- class hdmf.validate.validator.DatasetValidator(spec, validator_map)
Bases:
BaseStorageValidator
A class for validating DatasetBuilders against DatasetSpecs
- Parameters:
spec (
DatasetSpec
) – the specification to use to validatevalidator_map (
ValidatorMap
) – the ValidatorMap to use during validation
- validate(builder)
- Parameters:
builder (
DatasetBuilder
) – the builder to validate- Returns:
a list of Errors
- Return type:
- class hdmf.validate.validator.GroupValidator(spec, validator_map)
Bases:
BaseStorageValidator
A class for validating GroupBuilders against GroupSpecs
- Parameters:
spec (
GroupSpec
) – the specification to use to validatevalidator_map (
ValidatorMap
) – the ValidatorMap to use during validation
- validate(builder)
- Parameters:
builder (
GroupBuilder
) – the builder to validate- Returns:
a list of Errors
- Return type:
- class hdmf.validate.validator.SpecMatches(spec)
Bases:
object
A utility class to hold a spec and the builders matched to it
- add(builder)
- class hdmf.validate.validator.SpecMatcher(vmap, specs)
Bases:
object
Matches a set of builders against a set of specs
This class is intended to isolate the task of choosing which spec a builder should be validated against from the task of performing that validation.
- property unmatched_builders
Returns the builders for which no matching spec was found
These builders can be considered superfluous, and will generate a warning in the future.
- property spec_matches
Returns a list of tuples of (spec, assigned builders)
- assign_to_specs(builders)
Assigns a set of builders against a set of specs (many-to-one)
In the case that no matching spec is found, a builder will be added to a list of unmatched builders.