Limit the return value of the [random:number] token

Created on 9 September 2018, almost 6 years ago
Updated 26 October 2023, 8 months ago

Hi,

I want to use the Token module random number generator, but it says use [random:number] to generate "A random number from 0 to 2147483647".

How can I change this and get fixed number of digits?

For example, I need a 4 digits in each generated number (1000 to 9999). Or only 3 digits in each number (from 001 to 100).

Thank you,

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇱🇧Lebanon C.E.A

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇭Switzerland Berdir Switzerland

    This seems useful but the token description needs to be updated to explain the allowed options. Tests would be good as well, not sure if we already have random number tests.

  • 🇮🇳India anweshasinha

    Hi,
    I have changed the token description and re generated the patch. I have tested the patch in Drupal 10.0.12-dev and the patch was working properly in my system. Could you please review the patch

Production build 0.69.0 2024