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