UNPKG

json-schema-to-yup

Version:

Build a Yup schema from a JSON Schema. Also supports custom/alternative schema models such as GraphQL type defs

29 lines (22 loc) 528 B
import { Constraint } from '../constraints/base'; function createNumericConstraint(typer) { return new NumericConstraint(typer); } class NumericConstraint extends Constraint { constructor(typer) { super(typer); } transform(value) { return this.typer.toNumber(value); } isValidConstraint(value) { return this.typer.isNumberLike(value); } get explainConstraintValidMsg() { return `Must be a number or convertible to a number`; } } export { createNumericConstraint, NumericConstraint };