UNPKG

@try-at-software/input-elements

Version:

A package providing different input elements that are extensible and easily configurable for your custom needs.

14 lines (13 loc) 516 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.restrictEmptyText = void 0; function restrictEmptyText(errorMessage) { return (newValue) => { let error = ''; // If the new value contains only whitespace characters or is empty. if (!newValue || newValue.length <= 0 || !/\S/.test(newValue)) error = errorMessage || 'The input should not be empty!'; return error; }; } exports.restrictEmptyText = restrictEmptyText;