-
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(inequality): add validator for inequality operator
- Loading branch information
1 parent
cb247f8
commit caee113
Showing
3 changed files
with
24 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 |
---|---|---|
|
@@ -18,6 +18,7 @@ export { | |
lte, | ||
maxCount, | ||
minCount, | ||
ne, | ||
nonEmpty, | ||
nullish, | ||
number, | ||
|
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,21 @@ | ||
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
|
||
import { shouldBeBut } from "../utils.ts"; | ||
import { ScalarValidator } from "../../utils.ts"; | ||
|
||
export class InequalityValidator<const A = unknown> | ||
extends ScalarValidator<unknown, A> { | ||
constructor(public value: A) { | ||
super(); | ||
super.expect(shouldBeBut); | ||
} | ||
|
||
override is(input: unknown): input is A { | ||
return input !== this.value; | ||
} | ||
|
||
override toString(): string { | ||
return `!== ${this.value}`; | ||
} | ||
} |