Skip to content

Expressions: New simple functions #1176

@olemartinorg

Description

@olemartinorg

Extracted from #646.

We should implement some new simple functions in the expression language. All of these implementations should be fairly easy, but if any of these presents problems during the implementation phase, new issues should be created for them specifically.

List of functions we need:

  • round
    • Rounds a number to an integer, or optionally a decimal with a configurable amount of decimal points
  • text
    • Should look up a value from a text resource, or from a language key. Additional arguments should be considered parameters to the text resource, if any are provided. Returns string or null
  • strLength / stringLength / numCharacters
    • Function taking a sting as an argument and returns the number for characters in the string (note: the number of characters is not the same as the number for bytes)
  • language
    • Function with no parameters, returns the currently selected language (i.e. nb, en, etc).
  • contains
    • String-checking function to check if the second parameter (a string) is inside the first parameter (also a string)
  • notContains
    • Synonym for ["not", ["contains", ...]]
  • endsWith
    • String-checking function to check if the first parameter ends with the string in the second parameter
  • startsWith
    • Same as the above, but for the beginning of the text
  • commaContains
    • Special function for checking if a value is included in a comma-separated list of strings.
    • Can also be represented as a shortcut to ["or", ["equals", string, input], ["startsWith", string, ["concat", input, ","]], ["endsWith", string, ["concat", ",", input]], ["contains", string, ["concat", ",", input, ","]]]
  • displayValue Created a separate issue
  • upperCase
    • Takes a string, turns it into UPPERCASE
  • lowerCase
    • Takes a string, turns it into lowercase

Metadata

Metadata

Assignees

Labels

area/logicrelated to logic/dynamics/expressionsfeature-completeFeatures needed for parity with Altinn 2 (target: June 2023)kind/feature-requestNew feature or request

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions