-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core-webhooks): cast params in condition checks (#2887)
- Loading branch information
1 parent
a201d64
commit 1016bd5
Showing
2 changed files
with
85 additions
and
9 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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
export const between = (actual, expected): boolean => actual > expected.min && actual < expected.max; | ||
import { Utils } from "@arkecosystem/crypto"; | ||
|
||
const toBoolean = (value): boolean => value.toString().toLowerCase().trim() === "true" ? true : false; | ||
|
||
export const between = (actual, expected): boolean => gt(actual, expected.min) && lt(actual, expected.max); | ||
export const contains = (actual, expected): boolean => actual.includes(expected); | ||
export const eq = (actual, expected): boolean => actual === expected; | ||
export const falsy = (actual): boolean => actual === false; | ||
export const gt = (actual, expected): boolean => actual > expected; | ||
export const gte = (actual, expected): boolean => actual >= expected; | ||
export const lt = (actual, expected): boolean => actual < expected; | ||
export const lte = (actual, expected): boolean => actual <= expected; | ||
export const ne = (actual, expected): boolean => actual !== expected; | ||
export const eq = (actual, expected): boolean => JSON.stringify(actual) === JSON.stringify(expected); | ||
export const falsy = (actual): boolean => actual === false || !toBoolean(actual); | ||
export const gt = (actual, expected): boolean => Utils.BigNumber.make(actual).gt(expected); | ||
export const gte = (actual, expected): boolean => Utils.BigNumber.make(actual).gte(expected); | ||
export const lt = (actual, expected): boolean => Utils.BigNumber.make(actual).lt(expected); | ||
export const lte = (actual, expected): boolean => Utils.BigNumber.make(actual).lte(expected); | ||
export const ne = (actual, expected): boolean => !eq(actual, expected); | ||
export const notBetween = (actual, expected): boolean => !between(actual, expected); | ||
export const regexp = (actual, expected): boolean => new RegExp(expected).test(actual); | ||
export const truthy = (actual): boolean => actual === true; | ||
export const truthy = (actual): boolean => actual === true || toBoolean(actual); |