Skip to main content

matches_kind

Function matches_kind 

Source
pub fn matches_kind(value: &Scalar, kind: ScalarKind) -> bool
Expand description

Does value match scalar kind kind? Mirrors Python’s matches_kind – validation only checks, it never converts (see docs/design/model.md §10).

Verified against Python’s real schema.py::matches_kind before implementing (issue #105’s first attempt got this wrong by reasoning from first principles instead of checking – caught by the parity corpus, omnist/tests/parity.rs, before merge): Date/Time/ Datetime match either the real document::Scalar variant or a plain Str whose text independently shape-validates (is_iso_date/is_iso_time/is_iso_datetime) – Python’s own matches_kind does exactly this hybrid check (a real datetime.date object, or a string _is_iso-shaped for one), so a JSON- or XML-sourced document with a date-shaped string field genuinely satisfies kind: date at validate time in Python, with no materialize upgrade required first. This is unlike Integer/ Number, which stay strict (Python’s own matches_kind has no string-shape fallback for those).