mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-23 14:39:32 +08:00
105 lines
3.4 KiB
YAML
105 lines
3.4 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/actions.yaml.njk
|
|
vars:
|
|
pageId: Validate
|
|
pageTitle: Validate
|
|
filePath: actions/Validate.yaml
|
|
types: |
|
|
```
|
|
(void): void
|
|
(blockId: string): void
|
|
(blockIds: string[]): void
|
|
(blockIds: string[]): void
|
|
(params: {
|
|
blockId?: string|string[],
|
|
regex?: string|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.
|
|
|
|
The first time a `Validate` action is called, validation errors and warnings are shown to the user. The `Reset` action resets the validation status and the page `state`. The `ResetValidation` action resets only the validation status.
|
|
|
|
The `Validate` action `blockIds` or `regex` params are used to limit which blocks are validated. Only the matched blocks will be validated, and validation results are shown for only those matched blocks.
|
|
|
|
params: |
|
|
###### void
|
|
The `Validate` action validates all blocks on the page if called without params.
|
|
|
|
###### string
|
|
A blockId of the block to validate.
|
|
|
|
###### string[]
|
|
An array of blockIds of the blocks to validate.
|
|
|
|
###### object
|
|
- `blockId?: string|string[]`: A blockId or an array of the blockIds of the blocks to validate.
|
|
- `regex?: string|string[]`: A regex string pattern or an array of regex string patterns to match the blockIds to validate.
|
|
|
|
examples: |
|
|
###### Validate all inputs on the page:
|
|
```yaml
|
|
- id: validate_all
|
|
type: Validate
|
|
```
|
|
|
|
###### Validate a single input:
|
|
```yaml
|
|
- id: validate_my_input
|
|
type: Validate
|
|
params: my_input
|
|
```
|
|
|
|
###### Validate a list of inputs:
|
|
```yaml
|
|
- id: validate_input_a_and_b
|
|
type: Validate
|
|
params:
|
|
- my_input_a
|
|
- my_input_b
|
|
```
|
|
|
|
###### Validate all inputs matching a regex pattern:
|
|
```yaml
|
|
- id: validate_foo
|
|
type: Validate
|
|
params:
|
|
regex: ^foo\.
|
|
```
|
|
|
|
###### Validate all inputs matching a list of regex patterns:
|
|
```yaml
|
|
- id: validate_foo_and_price
|
|
type: Validate
|
|
params:
|
|
regex:
|
|
- ^foo\.
|
|
- ^.*price.*$
|
|
```
|
|
|
|
###### Validate all inputs matching a list of regex patterns and a blockId:
|
|
```yaml
|
|
- id: validate_foo_price_and_my_input
|
|
type: Validate
|
|
params:
|
|
blockId: my_input
|
|
regex:
|
|
- ^foo\.
|
|
- ^.*price.*$
|
|
```
|