-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added documentation for the unique
- Loading branch information
1 parent
32fb486
commit ea98865
Showing
5 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
title: unique | ||
--- | ||
|
||
Synth's `unique` generator type generates values which are guaranteed to be unique from its child generator. | ||
|
||
#### Example | ||
|
||
```json synth | ||
{ | ||
"type": "array", | ||
"length": { | ||
"type": "number", | ||
"constant": 10 | ||
}, | ||
"content": { | ||
"type": "object", | ||
"ticker": { | ||
"type": "unique", | ||
"content": { | ||
"type": "number", | ||
"range": { | ||
"low": 0, | ||
"high": 10, | ||
"step": 1 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
The unique generator works by trying the inner generator repeatedly until it receives a value which it hasn't seen yet. | ||
|
||
By default, the unique generator will give up if it sees the same value more than 64 times but this value can be specified using the `retries` property. | ||
|
||
Below is an example of a generator which will fail since the inner generator cannot generate 20 distinct values. | ||
|
||
```json synth | ||
{ | ||
"type": "array", | ||
"length": { | ||
"type": "number", | ||
"constant": 20 | ||
}, | ||
"content": { | ||
"type": "object", | ||
"ticker": { | ||
"type": "unique", | ||
"content": { | ||
"type": "number", | ||
"range": { | ||
"low": 0, | ||
"high": 10, | ||
"step": 1 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters