Skip to content

Commit

Permalink
ci(validator.test.ts): add test for skip validation functionality to …
Browse files Browse the repository at this point in the history
…ensure fields can be skipped when skip is set to true
  • Loading branch information
Codycody31 committed Jan 3, 2024
1 parent 97a9c8f commit 1ec8c5b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions __tests__/validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,25 @@ describe("Validator - Regex Validation", () => {
});
});

describe("Validator - Skip Validation", () => {
it("should skip validation for fields if skip is true", () => {
const validator = new Validator(
{
name: { type: "string", required: true, skip: () => true },
},
{
name: {
type: "Name must be a string",
required: "Name is required",
},
}
);

expect(validator.validate({ name: "John Doe" })).resolves.toBe(true);
expect(validator.validate({})).resolves.toBe(true);
});
});

describe("Validator - Options", () => {
it("Should track the passed fields", () => {
const validator = new Validator(
Expand Down

0 comments on commit 1ec8c5b

Please sign in to comment.