-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gte): add validator for greater than or equal operator
- Loading branch information
1 parent
f42a6f4
commit 629919b
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ export { | |
empty, | ||
eq, | ||
gt, | ||
gte, | ||
instance, | ||
int, | ||
item, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
|
||
import { ScalarValidator } from "../../utils.ts"; | ||
import { shouldBeBut } from "../utils.ts"; | ||
|
||
export class GreaterThenOrEqualValidator<In> extends ScalarValidator<In> { | ||
constructor(public base: In) { | ||
super(); | ||
super.expect(shouldBeBut); | ||
} | ||
|
||
override is(input: In): input is In { | ||
return input >= this.base; | ||
} | ||
|
||
override toString(): string { | ||
return `>= ${this.base}`; | ||
} | ||
} |