swh.model.fields package

Submodules

swh.model.fields.compound module

swh.model.fields.compound.validate_against_schema(model, schema, value)[source]

Validate a value for the given model against the given schema.

Parameters:
  • model – the name of the model
  • schema – the schema to validate against
  • value – the value to validate
Returns:

True if the value is correct against the schema

Raises:

ValidationError if the value does not validate against the schema

swh.model.fields.compound.validate_all_keys(value, keys)[source]

Validate that all the given keys are present in value

swh.model.fields.compound.validate_any_key(value, keys)[source]

Validate that any of the given keys is present in value

swh.model.fields.hashes module

swh.model.fields.hashes.validate_hash(value, hash_type)[source]

Validate that the given value represents a hash of the given hash_type.

Parameters:
  • value – the value to check
  • hash_type – the type of hash the value is representing
Returns:

True if the hash validates

Raises:

ValueError if the hash does not validate

swh.model.fields.hashes.validate_sha1(sha1)[source]

Validate that sha1 is a valid sha1 hash

swh.model.fields.hashes.validate_sha1_git(sha1_git)[source]

Validate that sha1_git is a valid sha1_git hash

swh.model.fields.hashes.validate_sha256(sha256)[source]

Validate that sha256 is a valid sha256 hash

swh.model.fields.simple module

swh.model.fields.simple.validate_type(value, type)[source]

Validate that value is an integer

swh.model.fields.simple.validate_int(value)[source]

Validate that the given value is an int

swh.model.fields.simple.validate_str(value)[source]

Validate that the given value is a string

swh.model.fields.simple.validate_bytes(value)[source]

Validate that the given value is a bytes object

swh.model.fields.simple.validate_datetime(value)[source]

Validate that the given value is either a datetime, or a numeric number of seconds since the UNIX epoch.

swh.model.fields.simple.validate_enum(value, expected_values)[source]

Validate that value is contained in expected_values

Module contents