Fix the five classic validation errors#
Every error names its fix. These are the five you will actually meet, with the message you get and the line that resolves it.
1. A typo’d field
import battinfo
try:
battinfo.CellSpec(manufacture="Acme", model="X", format="coin", chemistry="Li-ion")
except TypeError as exc:
print(exc) # Unknown field(s), with a did-you-mean for manufacturer=
2. A bare-number quantity — quantities are objects, units are never implicit:
spec = battinfo.CellSpec(
manufacturer="Acme", model="X", format="coin", chemistry="Li-ion",
nominal_capacity={"value": 2.5, "unit": "Ah"}, # not nominal_capacity=2.5
)
print(spec.nominal_capacity)
The value itself is a number, so write 2.5, not "2.5". Text that is not a number, such as a cycle life of >1000, goes in value_text: cycle_life={"value_text": ">1000", "unit": "count"}.
Units are case-sensitive, because case can change magnitude: MV is a megavolt, so a nominal voltage in MV fails strict validation with a did-you-mean for mV. A unit spelled in another case that means the same, such as ah, passes with the warning semantic.unit_unmapped, which names the symbol to write (Ah) so the unit gets its EMMO IRI. battinfo properties show nominal_voltage lists the units a property accepts.
3. An invalid test kind
try:
battinfo.TestSpec(name="t", kind="cycle_life")
except Exception as exc:
print(str(exc)[:120]) # lists the valid kinds; use "cycling"
4. specs= as a list — it is a mapping of property name to value:
try:
battinfo.CellSpec(
manufacturer="Acme", model="X", format="coin", chemistry="Li-ion",
specs=[("nominal_voltage", 3.0)],
)
except TypeError as exc:
print(exc)
5. A dataset without a URL — schema requires a resolvable location:
ds = battinfo.Dataset(
name="No URL yet",
id="https://w3id.org/battinfo/dataset/1f8r-6v2k-9p4m-3t7x",
cell_instance_id="https://w3id.org/battinfo/cell/3m6k-9t2p-7x4h-9nq8",
)
try:
ds.to_record()
except ValueError as exc:
print(str(exc)[:120]) # set access_url= to the landing page or download URL
Check any record in the browser at battinfo.org/validate —
it runs the same canonical schemas as battinfo validate and the registry.