@modular-forms/qwik
Version:
The modular and type-safe form library for Qwik
14 lines (13 loc) • 352 B
JavaScript
import { $ } from '@builder.io/qwik';
/**
* Creates a validation function that checks the existence of an input.
*
* @param error The error message.
*
* @returns A validation function.
*/
export function required(error) {
return $((value) => (!value && value !== 0) || (Array.isArray(value) && !value.length)
? error
: '');
}