mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 05:32:09 +03:00
14 lines
391 B
TypeScript
14 lines
391 B
TypeScript
// Loaded from https://deno.land/x/validasaur/src/rules/max_number.ts
|
|
|
|
|
|
import type { Validity, Rule } from "../types.ts";
|
|
import { invalid } from "../utils.ts";
|
|
|
|
export function maxNumber(maxValue: number): Rule {
|
|
return function maxRule(value: any): Validity {
|
|
if (typeof value !== "number" || value > maxValue) {
|
|
return invalid("maxNumber", { value, maxValue });
|
|
}
|
|
};
|
|
}
|