/** * @module ui/form */ import type { IUIInput, IUIInputValidator } from 'jodit/types'; import { isURL } from 'jodit/core/helpers/checker/is-url'; import { trim } from 'jodit/core/helpers/string/trim'; /** * Input is required */ export const required = function (input: IUIInput): boolean { if (!trim(input.value).length) { input.error = 'Please fill out this field'; return false; } return true; }; /** * Input value should be valid URL */ export const url = function (input: IUIInput): boolean { if (!isURL(trim(input.value))) { input.error = 'Please enter a web address'; return false; } return true; };