LanguageValues and typesStandard typesCommerce and logistics
Barcode
On this page
What a barcode encodes, and which kind of barcode it is.
Use it when one field can hold several kinds, such as tickets and products together. If you only have product codes, Ean13 or UpcA alone is simpler.
Shape
One of these, each with its own fields:
| Variant | Field | Type | Required? |
|---|---|---|---|
Barcode.ean13 |
data |
Ean13 |
Yes |
Barcode.upc_a |
data |
UpcA |
Yes |
Barcode.code128 |
data |
Text |
Yes |
Barcode.qr_code |
data |
Text |
Yes |
Example
Barcode.qr_code { data: "https://example.com/tickets/42" }Good to know
- The others are
Barcode.ean13,Barcode.upc_aandBarcode.code128, each withdata. Anean13checks its digits.code128takes printable ASCII only. - It holds the data, not an image of the barcode.
==tells you whether two are the same.<andlist.sort_bydon't take it.
In JSON
An object of its variant's name, as tag, and the variant's fields, in a request, a response or json.write:
{"tag":"ean13","data":"4006381333931"}{"tag":"upc_a","data":"036000291452"}{"tag":"code128","data":"CTN-0042"}
Details
Text form, storage, how it is shown, and operations
Barcode is in the group Commerce and logistics, and has been in Jadpo since 0.1.0.
Text form
It has no single text form, so text.from and text.parse don't take it.
How it is stored
It is stored in 2 columns, each named for the field, _ and its suffix. This is {"tag":"code128","data":"CTN-0042"}:
| Column | Type | Holds |
|---|---|---|
<field>_kind |
text |
'code128' |
<field>_data |
text |
'CTN-0042' |
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
{"tag":"ean13","data":"4006381333931"} |
4006381333931 |
{"tag":"upc_a","data":"036000291452"} |
036000291452 |
{"tag":"code128","data":"CTN-0042"} |
CTN-0042 |
{"tag":"qr_code","data":"https://example.com/a1"} |
https://example.com/a1 |
Operations
It also takes text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-barcode.md.Built from Jadpo main at aee2e8f.