Validation whether a field value is numeric

Issue #482 resolved
Maximilian Peter created an issue

Hello Fidel,

I'm trying to configure my last steps for a new workflow, but there is one question I can't find a solution in your documentation.

Is it possible to do a Validation on a text field (custom field) for:

  • is the value of the field numeric ([0-9] and [,] are allowed)

After that I want to validate, whether the numeric value is <= a Project property value:

projectProperty("Aufwand_Grenze") <= toNumber(%{12018})

12018 is a single line textfield.

The Project Property is {Aufwand_Grenze=16}

Thanks in advance and greets

Max

Comments (9)

  1. Fidel Castro Armario repo owner

    You can implement both validations using "Boolean validator with math, date-time or text-string terms" with the following boolean expressions:

    1) Validate that field %{12018} contains a number which can contain , characters:

    matches(%{12018}, "(\\d(,\\d)?)+")
    

    2) Validate that field %{12018} is <= than number in project property Aufwand_Grenze:

    toNumber(projectProperty("Aufwand_Grenze")) <= toNumber(%{12018})
    

    You can also use a single boolean expression for both validations:

    matches(%{12018}, "(\\d(,\\d)?)+") AND toNumber(projectProperty("Aufwand_Grenze")) <= toNumber(%{12018})
    
  2. Maximilian Peter reporter

    I have a problem with the second validation.

    The value for the project property is 16. If the value für the customfield 12018 is 15, 14, 21 and so on...it works.

    But if the value is 15,25 (or something sperated by comma (,)) it doesn't work. In Germany the Standard for numeric values ist 15,25 and not 15.25. Is it possible to solve this problem?

  3. Fidel Castro Armario repo owner

    Hi Max,

    You can use the following boolean expression instead of the second one I initially provided:

    toNumber(replaceAll(projectProperty("Aufwand_Grenze"), ",", ".")) <= toNumber(%{12018})
    
  4. Maximilian Peter reporter

    Hey Fidel, works fine with a little change:

    toNumber(projectProperty("Aufwand_Grenze")) <= toNumber(replaceAll(projectProperty("%{12018}"), ",", "."))

    Thanks a lot.

    Max

  5. Log in to comment