@get-milano/core 2.1.0
    Preparing search index...

    Class MilanoType

    Index
    optional: boolean
    • Validates a value against this type and returns its canonical form, or null on mismatch.

      Rules, identical in every runtime:

      • null is valid only for optional types.
      • An int value is accepted where double is declared and is canonicalized to double, mirroring expression promotion. A double value never satisfies an int declaration.
      • An enum declaration is satisfied only by one of its members.
      • Records must match their declared shape exactly: missing non-optional fields and undeclared fields are mismatches, and a missing optional field canonicalizes to null.

      Parameters

      Returns MilanoValue | null

    • A closed set of member strings. Two enum types are the same exactly when their member sets are equal: enum identity is structural, like records.

      Parameters

      • members: Iterable<string>
      • optional: boolean = false

      Returns MilanoType

    • Parses a JSON type descriptor:

      • a primitive name string, with a trailing ? for optional ("int", "string?")
      • {"enum": [<member>...], "optional": <bool>}
      • {"array": <descriptor>, "optional": <bool>}
      • {"record": {<field>: <descriptor>}, "optional": <bool>}

      Parameters

      Returns MilanoType | null