lowdefy/packages/docs/actions/Validate.yaml

69 lines
2.2 KiB
YAML
Raw Normal View History

2021-01-19 18:36:43 +08:00
# 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.
2021-01-13 23:21:27 +08:00
_ref:
2021-01-28 18:51:02 +08:00
path: templates/actions.yaml.njk
2021-01-13 23:21:27 +08:00
vars:
pageId: Validate
pageTitle: Validate
2021-02-12 01:09:10 +08:00
filePath: actions/Validate.yaml
2021-01-28 18:51:02 +08:00
types: |
```
(void): void
(blockId: string): void
(blockIds: string[]): void
```
description: |
The `Validate` action is used to validate a users input, usually before information is inserted into a database using a request.
It is used in conjunction with the `required` and `validate` fields on input blocks. If the validation fails, the `Validate`
action will fail, and this will stop the execution of actions that are defined after it.
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
The first time a `Validate` action is called, validation error are shown to the user. The `Reset` action resets this.
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
Validate only validates the input blocks that are inside the context it is called from. Therefore, if you use two contexts
to separate two forms, only the one form will be validated.
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
params: |
###### void
The `Validate` action validates all blocks in the `context ` if called without params.
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
###### string
A blockId of the block to validate.
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
###### string[]
An array of blockIds of the blocks to validate.
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
examples: |
###### Validate all inputs in the context:
```yaml
- id: validate
type: Validate
```
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
###### Validate a single input:
```yaml
- id: validate_one
type: Validate
params: my_text_input
```
2021-01-13 23:21:27 +08:00
2021-01-28 18:51:02 +08:00
###### Validate a list of inputs:
```yaml
- id: validate_one
type: Validate
params:
- my_text_input_1
- my_text_input_2
```