s1seven / schema-tools

Tools to create, validate and render certificates using Material Identity JSON schemas
https://materialidentity.org/
Apache License 2.0
1 stars 1 forks source link

fix: add localization for Value, Minimum and Maximum in inspections for generatePdf #144

Closed eamon0989 closed 2 years ago

eamon0989 commented 2 years ago

Description

Inspection values were not localizing correctly for the Value, Minimum, and Maximum properties if the type was a string instead of a number. This is due to a check in localizeNumber that checks if the value is of type number, otherwise returning the original value.

else if (format === 'Number' && typeof value === 'number') {
    return localizeNumber(value, locales);
  }

My code localizes the number before it is passed to computeTextStyle, ensuring that it is correctly localized even if it is a string.

Fixes #143 Fixes thematerials-network/CoA-schemas#46

Before: image

After:

image

As you can see in the screenshot, the values for Value, Minimum and Maximum are now correctly localized (they contain commas instead of dots).

Type of change

Checklist:

sonarcloud[bot] commented 2 years ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

50.0% 50.0% Coverage
0.0% 0.0% Duplication