mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
14 lines
400 B
TypeScript
14 lines
400 B
TypeScript
|
// Loaded from https://deno.land/x/validasaur/src/rules/is_in.ts
|
||
|
|
||
|
|
||
|
import type { Validity, Rule, PrimitiveTypes } from "../types.ts";
|
||
|
import { invalid } from "../utils.ts";
|
||
|
|
||
|
export function isIn(allowedValues: PrimitiveTypes[]): Rule {
|
||
|
return function isInRule(value: any): Validity {
|
||
|
if (allowedValues.indexOf(value) < 0) {
|
||
|
return invalid("isIn", { value, allowedValues });
|
||
|
}
|
||
|
};
|
||
|
}
|