Ivandt logo

Numeric transformers

Transformers for numeric data manipulation

cleanNumbers

Cleans and normalizes numeric values. Parses strings into numbers, handles currency symbols, and controls decimal precision.

Payload:

PropertyTypeRequiredDefaultDescription
dropNonNumbersbooleanNofalseWhether to replace unparseable values with null. When false, invalid values are left unchanged
optionsICleanNumberOptionsNo-Options for cleaning and normalizing numbers

ICleanNumberOptions:

PropertyTypeDescription
decimalHandling'drop' | 'round' | 'ceil' | 'floor'How to handle decimals: 'drop' truncates, 'round' rounds to nearest, 'ceil' rounds up, 'floor' rounds down
decimalPlacesnumberNumber of decimal places to apply handling to; defaults to 0 (integer) when handling is specified
stripCurrencySymbolsbooleanWhether to strip currency symbols from input. If false, values with currency symbols are rejected (return null)
currencyPosition'prefix' | 'suffix' | 'both'Where currency symbols may appear: 'prefix' (start), 'suffix' (end), or 'both'. Default: 'both'
stripOnlyTheseCurrenciesstring[] | 'any'Which currency symbols to strip. 'any' strips all Unicode currency symbols ($, €, £, ¥, etc.). Array like ['$', '€'] only strips those specific symbols and rejects others. Default: 'any'
localestringLocale for number parsing (e.g., 'en-AU', 'de-DE', 'fr-FR'). Determines thousands and decimal separators. If not provided, defaults to Australian format (, for thousands, . for decimal)
{
  key: 'price',
  label: 'Price',
  type: 'numeric',
  transformers: [
    {
      action: 'cleanNumbers',
      payload: {
        dropNonNumbers: true,
        options: {
          stripCurrencySymbols: true,
          stripOnlyTheseCurrencies: 'any',
          decimalHandling: 'round',
          decimalPlaces: 2
        }
      }
    }
  ]
}

Examples:

US format (default):

  • Input: "$1,234.567" → Output: 1234.57
  • Input: "€99.99" → Output: 99.99

German format with locale:

options: {
  locale: 'de-DE',
  stripCurrencySymbols: true,
  decimalHandling: 'round',
  decimalPlaces: 2
}
  • Input: "€1.234,567" → Output: 1234.57
  • Input: "99,99" → Output: 99.99

French format with locale:

options: {
  locale: 'fr-FR',
  stripCurrencySymbols: true
}
  • Input: "1 234,56 €" → Output: 1234.56
  • Input: "99,99" → Output: 99.99

roundNumbers

Rounds numeric values to a specified number of decimal places. Non-numeric values are left unchanged.

Payload:

PropertyTypeRequiredDescription
decimalsnumberYesNumber of decimal places to round to
{
  key: 'score',
  label: 'Score',
  type: 'numeric',
  transformers: [
    {
      action: 'roundNumbers',
      payload: {
        decimals: 2
      }
    }
  ]
}

Example:

  • Input: 3.14159
  • Output: 3.14

scaleNumbers

Multiplies numeric values by a scaling factor. Only affects numeric values; other types are left unchanged.

Payload:

PropertyTypeRequiredDescription
factornumberYesMultiplication factor. If factor is 0, all values become 0
{
  key: 'percentage',
  label: 'Percentage',
  type: 'numeric',
  transformers: [
    {
      action: 'scaleNumbers',
      payload: {
        factor: 100
      }
    }
  ]
}

Example (converting decimals to percentages):

  • Input: 0.5
  • Output: 50

clampRange

Clamps numeric values to a specified minimum and maximum range. Values below the minimum are set to the minimum, and values above the maximum are set to the maximum.

Payload:

PropertyTypeRequiredDescription
minnumberNoMinimum allowed value
maxnumberNoMaximum allowed value
{
  key: 'rating',
  label: 'Rating',
  type: 'numeric',
  transformers: [
    {
      action: 'clampRange',
      payload: {
        min: 0,
        max: 100
      }
    }
  ]
}

Examples:

  • Input: 150 (with max: 100)

  • Output: 100

  • Input: -10 (with min: 0)

  • Output: 0


normalizeZScore

Normalizes numeric values using Z-score standardization. Transforms values to have mean=0 and standard deviation=1.

Formula: (value - mean) / std

Only affects numeric values. If std=0, all values become 0.

Payload: None required

{
  key: 'test_score',
  label: 'Test score',
  type: 'numeric',
  transformers: [
    {
      action: 'normalizeZScore'
    }
  ]
}

Example:

  • Input: [1, 2, 3] (mean=2, std≈0.816)
  • Output: [-1.22, 0, 1.22]