Explorer

definy.content-hash-mismatch

description
The message for the first content from index whose contentHash is not the SHA-256 of contentBytes (hashes, none if not Base64). none if all match
type
Fn(items: List<@definy.content-item>, hashes: List<Union{#none, #some(String)}>, index: Number) -> Union{#none, #some(String)}
expression
fn(items$1010, hashes$1011, index$1012) =>
  match @core.list-get(list: $1010, index: $1012) {
    #none(_) =>
      #none,
    #some(item$1013) =>
      let next$1014 = @definy.content-hash-mismatch(items: $1010, hashes: $1011, index: @core.plus(left: $1012, right: 1));
      match @core.list-get(list: $1011, index: $1012) {
        #none(_) =>
          #some(@core.string-concat(
            left: @core.string-concat(left: "contentBytes of '", right: $1013.content_hash),
            right: "' is missing"
          )),
        #some(hash$1015) =>
          match $1015 {
            #none(_) =>
              #some(@core.string-concat(
                left: @core.string-concat(left: "contentBytes of '", right: $1013.content_hash),
                right: "' is not Base64"
              )),
            #some(actual$1016) =>
              match @core.equal(left: $1016, right: $1013.content_hash) {
                true =>
                  $1014,
                false =>
                  #some(@core.string-concat(
                    left: @core.string-concat(
                      left: @core.string-concat(
                        left: @core.string-concat(left: "contentHash '", right: $1013.content_hash),
                        right: "' does not match SHA-256 of contentBytes ('"
                      ),
                      right: $1016
                    ),
                    right: "')"
                  ))
              }
          }
      }
  }
visibility
public
definy.content-hash-mismatch (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: 89iXXW9R4KP3yjxMp_0AJB5Fb8yBaYu982JcbJYjaTU
content hash: TTX7wigjsFgLln6gl6TFsLzT70QdLtERt_O_nzu6yfQ