Skip to content

support oneOf #201

@shanejonas

Description

@shanejonas

some failing tests i wrote

src/index.test.ts

  describe("handles validation for oneOf", () => {
    it("returns true when the data is valid", () => {
      const testSchema = {
        oneOf: [{ type: "string" }, { type: "number" }],
      } as JSONSchema;

      const result = validator(testSchema, "potato") as any;

      expect(result).toBe(true);
    });

    it("returns true when the data is null", () => {
      const testSchema = {
        oneOf: [{ type: "string" }, { type: "null" }],
      } as JSONSchema;

      const result = validator(testSchema, null) as any;

      expect(result).toBe(true);
    });
  });

Result

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions