UNPKG

logitar-validation

Version:

JavaScript validation library distributed by Logitar.

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