Skip to content

Union type #425

Description

@shimataro

Like this:

import assert from "assert";
import vs from "value-schema";

// accepts both number and integer
const schema = vs.union({
    schemas: [vs.number(), vs.string()],
});

assert.strictEqual(schema.applyTo(1), 1);
assert.strictEqual(schema.applyTo("a"), "a");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions