Skip to content

Random

library

Generates random test data: whole numbers, letter strings and IBANs. Values come from a general purpose random generator and are not suitable for passwords or tokens.

  • Kind Library, a global in every script
  • Category Utilities
  • Functions 3

Functions

  • number number Returns a random whole number.
  • string string Returns a random string of exactly `count` letters (a-z and A-Z, no digits or symbols).
  • iban string Returns a random IBAN with valid check digits and a random account number, written without spaces.
Random.number(max: number)→numberRandom.number(min: number, max: number)→number

Returns a random whole number. With one argument the range is 0 up to and including `max`; with two arguments it is `min` up to and including `max`. Arguments are cut to whole numbers. Throws when `min` is greater than `max`.

Parameters

min number
Lowest possible value
max number
Highest possible value

Returns

number A whole number inside the range, both ends included

Example runs in CI

print(Random.number(1, 100))
print(Random.string(8))
Random.string(count: number)→string

Returns a random string of exactly `count` letters (a-z and A-Z, no digits or symbols). Throws for a negative count.

Parameters

count number
Number of letters; 0 gives an empty string

Returns

string A string of `count` random letters
Random.iban(code: string, bank: string)→string

Returns a random IBAN with valid check digits and a random account number, written without spaces. The bank code must have the format of the country: four letters for `NL` (`ABNA`), eight digits for `DE`. Throws when the country code is unknown or the bank code does not fit the country.

Parameters

code string
Two-letter country code in capitals, like `NL` or `DE`
bank string
Bank code in the format of that country, like `ABNA` for NL

Returns

string An IBAN such as `NL14ABNA4813092681`

Example runs in CI

print(Random.iban("NL", "ABNA"))