LanguageValues and typesStandard typesCommerce and logistics
Rating
On this page
A rating on its own scale: 4.5/5.
Use it for reviews and scores. It keeps its scale with it, so 4 of 5 and 8 of 10 aren't mixed up. For a plain percentage score, use Percentage.
Shape
| Field | Type | Required? |
|---|---|---|
value |
Decimal |
Yes |
best |
Decimal |
Yes |
worst |
Decimal |
Yes |
Its parts keep these rules, and a value that breaks one fails with the rule's name:
best_above_worst: best > worstvalue_on_scale: worst <= value and value <= best
Example
Rating { value: 4.5 best: 5.0 worst: 1.0 }Good to know
bestmust be aboveworst, andvaluebetween them.==tells you whether two are the same.<andlist.sort_bydon't take it, so sort by one of its parts instead.
In JSON
An object of its parts, in a request, a response or json.write:
{"value":"4.5","best":"5","worst":"1"}{"value":"8","best":"10","worst":"0"}{"value":"92","best":"100","worst":"0"}
Details
Text form, storage, how it is shown, and operations
Rating 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 3 columns, each named for the field, _ and its suffix. This is {"value":"92","best":"100","worst":"0"}:
| Column | Type | Holds |
|---|---|---|
<field>_value |
numeric |
92 |
<field>_best |
numeric |
100 |
<field>_worst |
numeric |
0 |
How it is shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
{"value":"4.5","best":"5","worst":"1"} |
4.5/5 |
{"value":"8","best":"10","worst":"0"} |
8/10 |
{"value":"92","best":"100","worst":"0"} |
92/100 |
{"value":"1","best":"5","worst":"1"} |
1/5 |
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-rating.md.Built from Jadpo main at aee2e8f.