Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Validation constants for worksheet generation
*
* These constants define the limits for worksheet configuration.
* Keep these in sync across:
* - Zod schemas (config-schemas.ts)
* - Runtime validation (validation.ts)
* - UI components (forms, sliders, etc.)
*/
export const WORKSHEET_LIMITS = {
/** Maximum total problems across all pages */
MAX_TOTAL_PROBLEMS: 2000,
/** Maximum problems per page */
MAX_PROBLEMS_PER_PAGE: 100,
/** Maximum number of pages */
MAX_PAGES: 100,
/** Maximum columns per page */
MAX_COLS: 10,
/** Minimum/maximum digit range for problems */
DIGIT_RANGE: {
MIN: 1,
MAX: 5,
},
/** Font size limits */
FONT_SIZE: {
MIN: 8,
MAX: 32,
},
} as const
/**
* Validate that worksheet config doesn't exceed limits
*
* IMPORTANT: problemsPerPage * pages must not exceed MAX_TOTAL_PROBLEMS
*/
export function validateWorksheetLimits(
problemsPerPage: number,
pages: number
): {
valid: boolean
error?: string
} {
const total = problemsPerPage * pages
if (total > WORKSHEET_LIMITS.MAX_TOTAL_PROBLEMS) {
return {
valid: false,
error: `Total problems (${total}) exceeds maximum of ${WORKSHEET_LIMITS.MAX_TOTAL_PROBLEMS}`,
}
}
if (problemsPerPage > WORKSHEET_LIMITS.MAX_PROBLEMS_PER_PAGE) {
return {
valid: false,
error: `Problems per page (${problemsPerPage}) exceeds maximum of ${WORKSHEET_LIMITS.MAX_PROBLEMS_PER_PAGE}`,
}
}
if (pages > WORKSHEET_LIMITS.MAX_PAGES) {
return {
valid: false,
error: `Pages (${pages}) exceeds maximum of ${WORKSHEET_LIMITS.MAX_PAGES}`,
}
}
return { valid: true }
}
|