Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
validate / validate-issnOpenRuns on Liberas

ISSN

Validates an International Standard Serial Number (ISO 3297). input is 8 characters, or 9 with a hyphen-minus as the 5th (removed); nothing else: no spaces, no "ISSN" prefix, other lengths and input over 65,536 bytes are format. The 8 must be seven ASCII digits then a digit, X or x, else format. checksum: the sum of digits 1-7 times weights 8, 7, 6, 5, 4, 3, 2; check = (11 - sum mod 11) mod 11 with 10 written X; it must equal the 8th character (x read as X), else checksum. Valid gives issn (NNNN-NNNC, X uppercase) and ean13: the serial's EAN-13 (GS1 prefix 977): 977, digits 1-7, 00 (issue variant), then the GS1 check digit of those 12 (weights 3, 1, 3, … from the rightmost leftward; (10 - sum mod 10) mod 10).

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init validate-issn --lang rust
cd validate-issn && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)26 lines›
validate-issn.wit
package root:component;

world root {
  export liberas:validate/issn@0.1.0;
}
package liberas:validate@0.1.0 {
  interface issn {
    record issn-parts {
      issn: string,
      ean13: string,
    }

    enum issn-error {
      format,
      checksum,
    }

    variant issn-check {
      valid(issn-parts),
      invalid(issn-error),
    }

    check: func(input: string) -> issn-check;
  }
}
Test vectors17›
validate-issn.cases.json
[
  {
    "args": {
      "input": "0378-5955"
    }
  },
  {
    "args": {
      "input": "03785955"
    }
  },
  {
    "args": {
      "input": "0317-8471"
    }
  },
  {
    "args": {
      "input": "2049-3630"
    }
  },
  {
    "args": {
      "input": "0000-006X"
    }
  },
  {
    "args": {
      "input": "0000-006x"
    }
  },
  {
    "args": {
      "input": "1050-124X"
    }
  },
  {
    "args": {
      "input": "0378-5956"
    }
  },
  {
    "args": {
      "input": "0000-0060"
    }
  },
  {
    "args": {
      "input": "0378 5955"
    }
  },
  {
    "args": {
      "input": "0378--5955"
    }
  },
  {
    "args": {
      "input": "037-85955"
    }
  },
  {
    "args": {
      "input": "ISSN 0378-5955"
    }
  },
  {
    "args": {
      "input": "0378-595"
    }
  },
  {
    "args": {
      "input": "X378-5955"
    }
  },
  {
    "args": {
      "input": ""
    }
  },
  {
    "args": {
      "input": "0378-5955"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 17 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 1,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.