generatePositiveCheck()
generatePositiveCheck(
varName,ctx,customMessage?):CodeGenResult
Experimental
Generates inline code for the positive constraint (value > 0).
Parametersβ
varName: stringβ
The variable name to check
ctx: GeneratorContextβ
The generator context
customMessage?: stringβ
Optional custom error message
Returns: CodeGenResultβ
Generated code and updated context
Sinceβ
2.0.0
Exampleβ
const result = generatePositiveCheck("value", ctx);
// result.code = 'if (value <= 0) return "Number must be positive";'