UNPKG

logitar-validation

Version:

JavaScript validation library distributed by Logitar.

21 lines (20 loc) 745 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * A validation rule that checks if a value is less than or equal to a maximum value. * @param value The value to validate. * @param args The maximum value. * @returns The result of the validation rule execution. */ const maximumValue = (value, args) => { try { if (value > args) { return { severity: "error", message: "{{name}} must be at most {{maximumValue}}." }; } } catch (_) { return { severity: "warning", message: `Could not compare {{name}} ({{value}} | ${typeof value}) with args ({{maximumValue}} | ${typeof args}).` }; } return { severity: "information" }; }; exports.default = maximumValue;