MCPcopy Create free account
hub / github.com/Lemoncode/fonk / validator

Function validator

src/validators/max-length.ts:18–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 value.length <= length;
17
18export const validator: FieldValidationFunctionSync = fieldValidatorArgs => {
19 if (!fieldValidatorArgs.customArgs) {
20 throw new Error(BAD_PARAMETER);
21 }
22
23 const {
24 value,
25 customArgs = DEFAULT_PARAMS as LengthArgs,
26 message = defaultMessage,
27 } = fieldValidatorArgs;
28
29 const length = parseLengthParams(customArgs, BAD_PARAMETER);
30 const succeeded = isLengthValid(value, length, isStringLengthValid);
31
32 return {
33 succeeded,
34 message: succeeded
35 ? ''
36 : parseMessageWithCustomArgs(message as string, customArgs),
37 type: VALIDATOR_TYPE,
38 };
39};

Callers 1

max-length.spec.tsFile · 0.90

Calls 3

parseLengthParamsFunction · 0.90
isLengthValidFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…