generateBooleanValidation()
generateBooleanValidation(
varName,ctx,customTypeMessage?):object
Experimental
Generates complete validation code for a boolean schema. Boolean schemas only have type checking, no additional constraints.
Parametersโ
varName: stringโ
The variable name to validate
ctx: GeneratorContextโ
The generator context
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 = generateBooleanValidation("value", ctx);
// result.code = ['if (typeof value !== "boolean") return "Expected boolean";']