Overview
This article shows the design pattern of using linked generators with the ConcatGen Generator to concatenate different generated values to create a new type of generated value.
Example
Create an expiration date generator by concatenating values that generate:
- Month
- Year
- Concatenated to Month + / + Year
Generation Sequence From Left To Right
- Randomly generates a month number between 1 and 12
- Pad-Left the value of the month number generated with a zero when less than 10
- Randomly generate a year between a given startRange and a given endRange
- Concatenate the paddedMonth + / + year to yield a mm/yy expirationDate
Video Example
Step by Step Example
1. Create a new Domain and name it "CreditCard"
2. Create a new Attribute and name it "expireDate"
3. Assign the MonthNumberGen to the expireDate Attribute. Give it the alias "month"
4. Add the PadGen to the expireDate Attribute. Give it the alias "monthPadLeft"
5. Set the following parameters for the "monthPadLeft" Generator:
- attribute: #{self.gen1} (This references the monthNumberGen)
- padValue: 0
- padDirection: Left
- padLength: 2
6. Add the "RandomGen" to the expireDate Attribute and give it the alias "year"
7. Set the following parameters for the "year" Generator:
- startRange: 17
- endRange: 23
8. Add the "ConcatGen" to the expireDate Attribute and give it the alias "expireDate"
9. Add the following items to the "expireDate" gen
- #{self.gen2} (This is the monthPadLeft Generator)
- /
- #{self.gen3} (This is the year Generator)