@modular-forms/qwik
Version:
The modular and type-safe form library for Qwik
13 lines (12 loc) • 395 B
JavaScript
import { $ } from '@builder.io/qwik';
/**
* Creates a validation functions that validates the length of a string or array.
*
* @param requirement The maximum string or array length.
* @param error The error message.
*
* @returns A validation function.
*/
export function maxLength(requirement, error) {
return $((value) => value?.length && value.length > requirement ? error : '');
}