-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add sample for validator * addressing comment * address comment * add test * add test case for validator * address comment * address comment * fix merge conflict --------- (cherry picked from commit 0da23e1) Signed-off-by: Frank Lou <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7442d1a
commit ec2e7b2
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/org/opensearch/sdk/sample/helloworld/ExampleCustomSettingConfig.java
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,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.sdk.sample.helloworld; | ||
|
||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Setting.RegexValidator; | ||
import org.opensearch.common.settings.Setting.Property; | ||
|
||
/** | ||
* {@link ExampleCustomSettingConfig} contains the custom settings value and their static declarations. | ||
*/ | ||
public class ExampleCustomSettingConfig { | ||
private static final String FORBIDDEN_REGEX = "forbidden"; | ||
|
||
/** | ||
* A string setting. If the string setting matches the FORBIDDEN_REGEX string, the validation will fail. | ||
*/ | ||
public static final Setting<String> VALIDATED_SETTING = Setting.simpleString( | ||
"custom.validate", | ||
new RegexValidator(FORBIDDEN_REGEX), | ||
Property.NodeScope, | ||
Property.Dynamic | ||
); | ||
|
||
} |
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