Skip to content

Conversation

@krisxcrash
Copy link
Contributor

@krisxcrash krisxcrash commented Dec 16, 2025

This PR adds support for min and max HTML attributes to TextInputField and applies min={0} to all payroll and contractor payment numeric inputs to prevent users from entering negative values.

SDK-200

Changes

Core Components

  • TextInputTypes.ts: Added min and max to the interface, extending from InputHTMLAttributes
  • TextInput.tsx: Updated to extract and pass min and max props to the underlying Input component

Payroll Forms

  • PayrollEditEmployeePresentation.tsx: Added min={0} to:
    • Regular hours fields (regular, overtime, double overtime)
    • Additional earnings fields (bonus, commission, paycheck tips, correction payment, cash tips)
    • Reimbursement fields
  • TimeOffField.tsx: Added min={0} to time off hour inputs

Contractor Payment Forms

  • EditContractorPaymentPresentation.tsx: Added min={0} to:
    • Hours worked field
    • Fixed wage field
    • Bonus field
    • Reimbursement field

Testing & Documentation

  • Added test case in TextInput.test.tsx to verify min and max attributes render correctly
  • Added Storybook story NumberInputWithMinMax demonstrating the feature with multiple examples
  • All existing tests pass (39 payroll tests, 12 TextInput tests, 23 contractor tests)

Usage Example

<TextInputField
  type="number"
  min={0}
  label="Hours Worked"
  name="hours"
/>
<NumberInputField
  min={0}
  max={100}
  label="Score"
  name="score"
  format="currency"
/>

Testing

✅ All existing unit tests pass
✅ Added new test for min/max attribute rendering
✅ Verified in Storybook that validation prevents negative numbers
✅ No linter errors

Screenshots/Demo

See the new Storybook story: UI/Form/Fields/Text > NumberInputWithMinMax

Breaking Changes

None. This is a backwards-compatible enhancement. The min and max props are optional.

Screen.Recording.2025-12-16.at.11.00.54.AM.mov

@krisxcrash krisxcrash requested review from dmortal, jeffredodd and serikjensen and removed request for jeffredodd and serikjensen December 16, 2025 18:46
@krisxcrash krisxcrash self-assigned this Dec 16, 2025
Copy link
Member

@serikjensen serikjensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One check on this one, do we have confidence that the API disallows negative values for each of these? i'm pretty sure that's the case, but we wanted to double check

@krisxcrash
Copy link
Contributor Author

One check on this one, do we have confidence that the API disallows negative values for each of these? i'm pretty sure that's the case, but we wanted to double check

From what I found in ZP, it looks like negative values are not allowed with exception of two scenarios.

API Endpoint Field Type Negative Values Allowed?
Contractor Payments wage, bonus, reimbursement, hours, rate ❌ No (except correction payments for wage)
Employee Payrolls amount, hours, net_amount, deductions ❌ No
Time Off hours requested/used ❌ No
Time Off balance adjustments ⚠️ Depends on policy's allow_negative_balance setting
Time Off payout hours (termination) ❌ No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants