Skip to content

Conversation

@doneill
Copy link
Collaborator

@doneill doneill commented Jun 13, 2025

Summary

Handle comma decimal separators in JSON Schema number fields

Fixes

#17

Proposed changes

  1. Utility Function (normalizeDecimalSeparators):
    • Converts comma decimal separators to periods (e.g., "12,99" → "12.99")
    • Handles negative numbers ("-15,75" → "-15.75")
    • Safely ignores non-numeric strings, numbers, and complex formats
    • Uses strict regex pattern (/^-?\d+,\d+$/) to only convert simple decimal commas
  2. Integration (normalizeNumberFields):
    - Automatically processes all number fields in schema during validation
    - Normalizes default, minimum, and maximum values
    - Uses traverseSchema to handle nested objects
  3. Validation Pipeline:
    - Integrated into validateJSONSchema before other validation steps
    - Preserves all existing functionality

Test

  • Run all the tests yarn test
  • Make sure all tests pass

@doneill doneill self-assigned this Jun 13, 2025
@doneill doneill changed the title Localized Normalize decimal separators Jun 13, 2025
@doneill doneill merged commit c0ee030 into develop Jun 13, 2025
2 checks passed
@doneill doneill deleted the 17-localized-decimal-separator branch July 16, 2025 22:35
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.

1 participant