def kind

ezmcp@0.1.0.0 · src/openapi.bend:1369

import ezmcp@0.1.0.0/src/openapi.bend as Openapi
import Base
import emerging-ezjson@1.2.0.0/main.bend as Json
import emerging-ezjson@1.2.0.0/src/value.bend as Value

1369# whether a value is of the JSON Schema type named `typ`: string, number,
1370# integer (a number whose text is an integer), boolean, array, object or
1371# null; true for a name JSON Schema does not have
1372def kind(+typ: String, +val: Value.Json) -> Bool:
1373  +int = kind.int(val)
1374  Bool.pick(Bool, String.eq(typ, "integer"), int,
1375    Bool.pick(Bool, String.eq(typ, "string"), kind.str(val),
1376      Bool.pick(Bool, String.eq(typ, "number"), kind.num(val),
1377        Bool.pick(Bool, String.eq(typ, "boolean"), kind.bool(val),
1378          Bool.pick(Bool, String.eq(typ, "array"), Json.is_arr(val),
1379            Bool.pick(Bool, String.eq(typ, "object"), Json.is_obj(val),
1380              Bool.pick(Bool, String.eq(typ, "null"), is_null(val), True{})))))))

Uses (12)

Used by (2)