lowdefy/packages/docs/operators/_random.yaml
2021-01-27 11:51:43 +02:00

98 lines
2.8 KiB
YAML

# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _random
pageTitle: _random
types: |
```
(type: string): string | number
(arguments: {type: string, length?: number, max?: number, min?: number}): string | number
```
description: |
The `_random` operator returns a random string or number. The types it accepts are `string`, `integer`, or `float`.
arguments: |
#### string
The type to generate. One of `string`, `integer`, or `float`.
#### object
- `type: string`: __Required__ - The type to generate. One of `string`, `integer`, or `float`.
- `length: string`: The length of the string to generate if type is `string`. Default is `8`.
- `max: number`: The maximum possible number if type is one of `integer` or `float`. Default is `100` if `integer` or `1` if `float`.
- `min: number`: The minimum possible number if type is one of `integer` or `float`. Default is `0`.
examples: |
#### Random string:
```yaml
_random: string
```
Returns: Random string of length 8.
```yaml
_random:
type: string
```
Returns: Random string of length 8.
#### Random integer:
```yaml
_random: integer
```
Returns: Random integer between 0 and 100 inclusive.
```yaml
_random:
type: integer
```
Returns: Random integer between 0 and 100 inclusive.
#### Random float:
```yaml
_random: float
```
Returns: Random float between 0 and 1 inclusive.
```yaml
_random:
type: float
```
Returns: Random float between 0 and 1 inclusive.
#### Random string of length 12:
```yaml
_random:
type: string
length: 12
```
Returns: Random string of length 12.
#### Random integer between 1 and 6 (Dice roll):
```yaml
_random:
type: integer
min: 1
max: 6
```
Returns: Random integer between 1 and 6 inclusive.
#### Random float between 34.2 and 42.89:
```yaml
_random:
type: float
min: 34.2
max: 42.89
```
Returns: Random float between 34.2 and 42.89 inclusive.