Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
barcode / barcode-codabarOpenRuns on Liberas

Codabar

Codabar (ANSI/AIM BC3-1995) of text: 3 to 80 characters, the first and the last a start/stop character A, B, C or D (uppercase), those between from 0–9 and - $ : / . +; anything else is an error (no T N * E, no check character). text echoes the input. modules: each character's seven elements (four bars, three spaces, bar first) as the standard's table, narrow = 1 module, wide = 3, one narrow space (0) between characters, none outside; no quiet zones.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init barcode-codabar --lang rust
cd barcode-codabar && 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)21 lines›
barcode-codabar.wit
package root:component;

world root {
  import liberas:barcode/types@0.1.0;

  export liberas:barcode/linear-encode@0.1.0;
}
package liberas:barcode@0.1.0 {
  interface types {
    record linear {
      text: string,
      modules: string,
    }
  }
  interface linear-encode {
    use types.{linear};

    encode: func(text: string) -> result<linear, string>;
  }
}
Test vectors15›
barcode-codabar.cases.json
[
  {
    "args": {
      "text": "A40156B"
    }
  },
  {
    "args": {
      "text": "C1234D"
    }
  },
  {
    "args": {
      "text": "A0B"
    }
  },
  {
    "args": {
      "text": "D-$:/.+D"
    }
  },
  {
    "args": {
      "text": "B0123456789C"
    }
  },
  {
    "args": {
      "text": "A111111111111111111111111111111111111111111111111111111111111111111111111111111A"
    }
  },
  {
    "args": {
      "text": "A31117013206375B"
    }
  },
  {
    "args": {
      "text": "C$12.50D"
    }
  },
  {
    "args": {
      "text": ""
    }
  },
  {
    "args": {
      "text": "AB"
    }
  },
  {
    "args": {
      "text": "a123b"
    }
  },
  {
    "args": {
      "text": "A12E"
    }
  },
  {
    "args": {
      "text": "1234"
    }
  },
  {
    "args": {
      "text": "A1A2B"
    }
  },
  {
    "args": {
      "text": "A1111111111111111111111111111111111111111111111111111111111111111111111111111111A"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 15 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%.