From 872216e355f6aac2c97460d9d6fd2b84a674972f Mon Sep 17 00:00:00 2001 From: Hieromon Ikasamo Date: Wed, 4 Sep 2019 12:22:33 +0900 Subject: [PATCH] Describes AutoConnectAux::isValid --- mkdocs/achandling.md | 48 ++++++++++++++++++++++++++++++++++++++++++-- mkdocs/changelog.md | 3 ++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/mkdocs/achandling.md b/mkdocs/achandling.md index 121b299..7f4f797 100644 --- a/mkdocs/achandling.md +++ b/mkdocs/achandling.md @@ -720,11 +720,55 @@ By giving a [pattern](apielements.md#pattern) to [AutoConnectInput](apielements. If you are not familiar with regular expressions, you may feel that description very strange. Matter of fact, it's a strange description for those who are unfamiliar with the formal languages. If your regular expression can not interpret the intended syntax and semantics, you can use an online tester. The [regex101](https://regex101.com/) is an exceptional online tool for testing and debugging regular expressions. -### Validate input data +### Input data validation The [pattern](apielements.md#pattern) attribute of [AutoConnectInput](apielements.md#autoconnectinput) only determines the data consistency on the web browser based on the given regular expression. In order to guarantee the validity of input data, it is necessary to verify it before actually using it. -You can validate input data from [AutoConnectInput](apielements.md#autoconnectinput) using the [isValid](apielements.md#isvalid) function before actually processing it. The [isValid](apielements.md#isvalid) function determines whether the [value](apielements.md#value_3) currently stored in [AutoConnectInput](apielements.md#autoconnectinput) matches the [pattern](apielements.md#pattern). +You can validate input data from [AutoConnectInput](apielements.md#autoconnectinput) using the [isValid](apielements.md#isvalid) function before actually processing it. The [isValid](apielements.md#isvalid) function determines whether the [value](apielements.md#value_3) currently stored in [AutoConnectInput](apielements.md#autoconnectinput) matches the [pattern](apielements.md#pattern). + +You can also use the [AutoConnectAux::isValid](apiaux.md#isvalid) function to verify the data input to all [AutoConnectInput](apielements.md#autoconnectinput) elements on the custom Web page at once. The two sketches below show the difference between using [AutoConnectInput::isValid](apielements.md#isvalid) and using [AutoConnectAux::isValid](apiaux.md#isvalid). In both cases, it verifies the input data of the same AutoConnectInput, but in the case of using AutoConnectAux::isValid, the amount of sketch coding is small. + +**A common declaration** + +```cpp +const char PAGE[] PROGMEM = R"( +{ + "title": "Custom page", + "uri": "/page", + "menu": true, + "element": [ + { + "name": "input1", + "type": "ACInput", + "pattern": "^[0-9]{4}$" + }, + { + "name": "input2", + "type": "ACInput", + "pattern": "^[a-zA-Z]{4}$" + } + ] +} +)"; +AutoConnectAux page; +page.load(PAGE); +``` + +**Using AutoConnectInput::isValid** + +```cpp +AutoConnectInput& input1 = page["input1"].as(); +AutoConnectInput& input2 = page["input2"].as(); +if (!input1.isValid() || !input2.isValid()) + Serial.println("Validation error"); +``` + +**Using AutoConnectAux::isValid** + +```cpp +if (!page.isValid()) + Serial.println("Validation error"); +``` ### Convert data to actually type diff --git a/mkdocs/changelog.md b/mkdocs/changelog.md index 5e20316..1cbc429 100644 --- a/mkdocs/changelog.md +++ b/mkdocs/changelog.md @@ -1,8 +1,9 @@ -#### [1.0.0] Aug. 29, 2019 +#### [1.0.0] Sep. 5, 2019 - Supports Arduino core for ESP32 1.0.3. - Supports AutoConnectUpdate for the [OTA update](otaupdate.md). - Supports Preferences for saving credentials with ESP32 core 1.0.3 and later. **In ESP32, the credentials stored past in EEPROM will lose**. - Supports [**AutoConnectAux::isValid**](apiaux.md#isvalid) function. +- Supports the **global** attribute with all AutoConnectElements. #### [0.9.12] Aug. 18, 2019 - Fixed missing captive portal notifications on the newer mobile OS client. As a result of this fix, the SoftAP default IP address and gateway have been changed to **172.217.28.1**.