* Returns a randomly chosen value or null if not applicable. * @param {Random} random Random number generator * @return {mixed} Randomly chosen value
(random)
| 115 | * @return {mixed} Randomly chosen value |
| 116 | */ |
| 117 | randomizeValue (random) { |
| 118 | const value = super.randomizeValue(random) |
| 119 | if (value !== null) { |
| 120 | return value |
| 121 | } |
| 122 | if (this._randomizeSize !== null) { |
| 123 | // Use randomize size |
| 124 | return random.nextBytes(this._randomizeSize) |
| 125 | } else if (this.getMinSize() !== null) { |
| 126 | // Use the min size |
| 127 | return random.nextBytes(this.getMinSize()) |
| 128 | } else if (this.isValid()) { |
| 129 | // Use the current value's size to |
| 130 | // produce the same amount of random bytes |
| 131 | return random.nextBytes(this.getValue().length) |
| 132 | } |
| 133 | return null |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Serializes the field value to a JSON serializable value. |
nothing calls this directly
no test coverage detected