-
Notifications
You must be signed in to change notification settings - Fork 10
Expressions
Márcio Mendes edited this page Oct 30, 2017
·
4 revisions
Expressions can be used to perform certain operations on the data to extend validation methods or work with more dynamic data.
- Used to concatenate list of params with pattern (param1|param2)
how to use: concatenate(arg1|arg2)
example | result
concatenate(test|451) | test451
- expression can be combined with other expressions →
concatenate(cpf()|test) - 39703704855test
- Used to generate a valid CPF with or without format
how to use: cpf() or cpf(f)
example | result
cpf() | 13224456247
cpf(f) | 132.244.562.47
- Used to generate a valid CNPJ with or without format
how to use: cnpj() or cnpj(f)
example | result
cnpj() | 12072949000186
cnpj(f) | 12.072.949/0001-86
- Used to make simple math operations
how to use: math(num1|operator:type|num2)
example | parse | result
math(5|add:d|2.5) | (5.0 + 2.5) | 7.5
math(5|add:i|2.5) | (5.0 + 2.5) | 7
- num1 - first argument
- num2 - second argument
- operator - used operator (add | sub | mul | div)
- type - return data type ( i - integer, d - decimal)
- expression can be combined with other expressions →
math(tonumber(R$16,70|double)|sub:d|3)
- Used to return the current time based on format
how to use: now(format) or now(format|operator)
example | result
now(HH:mm:ss) | 15:44:10
now(HH:mm:ss|+3h) | 18:44:10
- Used to return a random value
how to use: random(num) or random(num|num)
example | result
random(n|5) | 98714
random(l|3) | mme
random(3|7) | 6
- Used to return only number of string value
how to use: tonumber(content|format)
example | result
tonumber(R$16,70 | i) | 16
tonumber(R$16,70 | d) | 16.7