Aller au contenu principal

generateArrayValidation()

generateArrayValidation(varName, ctx, constraints?, customTypeMessage?): object

Experimental

Generates complete validation code for an array schema.


Parameters

varName: string

The variable name to validate

ctx: GeneratorContext

The generator context

constraints?: ArrayConstraintMeta

Array constraint metadata

customTypeMessage?: string

Optional custom type error message


Returns: object

Generated code lines and updated context

code: string[]

ctx: GeneratorContext


Since

2.0.0


Example

const result = generateArrayValidation("value", ctx, {
minLength: { value: 1 },
maxLength: { value: 10 },
itemGenerator: stringGenerator
});