Skip to content

Commit

Permalink
feat(empty): add validator for empty
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed May 18, 2023
1 parent dccc945 commit fd4dd0b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions validators/iterable/empty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license.
// This module is browser compatible.

import { isEmpty } from "../../deps.ts";
import { display, format, ScalarValidator } from "../../utils.ts";
import error from "../error.json" assert { type: "json" };

@display("empty")
export class EmptyValidator extends ScalarValidator<Iterable<unknown>> {
constructor() {
super();
super.expect(() => format(error.should_be, this));
}
override is = isEmpty;
}

0 comments on commit fd4dd0b

Please sign in to comment.