Skip to content

Latest commit

 

History

History
48 lines (38 loc) · 1.64 KB

AMENDMENT_VALIDATION.md

File metadata and controls

48 lines (38 loc) · 1.64 KB

Payroll Run Amendment Validation (Issue #624)

Status: ✅ Already Implemented

The validatePayrollRunAmendment() function is fully implemented in the codebase.

Location

packages/core/src/amendments/runAmendment.ts (lines 261-400+)

Features

  • 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

Usage

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);
}

Implementation Details

Implemented in commit 7148e9d as part of PR #623:

  • feat(amendments): add SDK support for payroll run amendments (#506)

Exported Functions

  • validatePayrollRunAmendment() - Main validation function
  • createPayrollRunAmendment() - Create amendment with validation
  • inspectPayrollRunAmendment() - Inspect amendment details
  • authorizePayrollRunAmendment() - Authorize amendment

Privacy & Security

  • Redacts sensitive information in error messages
  • Prevents PII leakage in amendment reasons
  • Validates authorizer permissions