The validatePayrollRunAmendment() function is fully implemented in the codebase.
packages/core/src/amendments/runAmendment.ts (lines 261-400+)
- Payroll ID validation - Ensures valid payroll identifier
- Revision validation - Must be positive safe integer
- Authorizer validation - Validates address format and whitelist
- Reason code validation - Enforces safe operational code format
- Status checks - Prevents amending terminal payroll states
- Commitment validation - Validates proposed payment commitments
- Duplicate detection - Prevents duplicate recipients
- Zero-diff detection - Optionally prevents no-op amendments
import { validatePayrollRunAmendment } from "@zk-payroll/core/amendments";
const result = validatePayrollRunAmendment(amendment, {
allowedAuthorizers: ["GA2C5RFPE..."],
currentPayrollStatus: "draft",
maxModificationsLimit: 100,
});
if (!result.ok) {
console.error(result.code, result.message);
}Implemented in commit 7148e9d as part of PR #623:
- feat(amendments): add SDK support for payroll run amendments (#506)
validatePayrollRunAmendment()- Main validation functioncreatePayrollRunAmendment()- Create amendment with validationinspectPayrollRunAmendment()- Inspect amendment detailsauthorizePayrollRunAmendment()- Authorize amendment
- Redacts sensitive information in error messages
- Prevents PII leakage in amendment reasons
- Validates authorizer permissions