File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { NonEmptyValidator } from "./validators/iterable/non_empty.ts";
1818import { AndValidator } from "./validators/operators/and.ts" ;
1919import { EqualityValidator } from "./validators/operators/eq.ts" ;
2020import { LessThenValidator } from "./validators/operators/lt.ts" ;
21+ import { LessThenOrEqualValidator } from "./validators/operators/lte.ts" ;
2122import { GreaterThenValidator } from "./validators/operators/gt.ts" ;
2223import { GreaterThenOrEqualValidator } from "./validators/operators/gte.ts" ;
2324import { TypeValidator } from "./validators/operators/typeof.ts" ;
@@ -35,6 +36,7 @@ export const optional = /* @__PURE__ */ lazy(OptionalValidator);
3536export const nullish = /* @__PURE__ */ new NullishValidator ( ) ;
3637export const eq = /* @__PURE__ */ lazy ( EqualityValidator ) ;
3738export const lt = /* @__PURE__ */ lazy ( LessThenValidator ) ;
39+ export const lte = /* @__PURE__ */ lazy ( LessThenOrEqualValidator ) ;
3840export const gt = /* @__PURE__ */ lazy ( GreaterThenValidator ) ;
3941export const gte = /* @__PURE__ */ lazy ( GreaterThenOrEqualValidator ) ;
4042export const and = /* @__PURE__ */ lazy ( AndValidator ) ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export {
1515 int ,
1616 item ,
1717 lt ,
18+ lte ,
1819 maxCount ,
1920 minCount ,
2021 nonEmpty ,
Original file line number Diff line number Diff line change 1+ // Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license.
2+ // This module is browser compatible.
3+
4+ import { ScalarValidator } from "../../utils.ts" ;
5+ import { shouldBeBut } from "../utils.ts" ;
6+
7+ export class LessThenOrEqualValidator < In > extends ScalarValidator < In > {
8+ constructor ( public base : In ) {
9+ super ( ) ;
10+ super . expect ( shouldBeBut ) ;
11+ }
12+
13+ override is ( input : In ) : input is In {
14+ return input <= this . base ;
15+ }
16+
17+ override toString ( ) : string {
18+ return `<= ${ this . base } ` ;
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments