diff --git a/docs/advanced/oauth_support.md b/docs/advanced/oauth_support.md index ae43dd1a7..b4a2c06a7 100644 --- a/docs/advanced/oauth_support.md +++ b/docs/advanced/oauth_support.md @@ -36,6 +36,7 @@ Auth can be used inside the entity tag. Use `type: "oauth"` in the entity list a - `encrypted` should be true if the user wants that particular field encrypted, otherwise, there is no need to have this parameter. - `required` specifies whether the field is required or not. The default value is true. - `defaultValue` is the initial input value (string, number, or boolean). + - `validators` array that is used to validate the values of fields using various [validators](../entity/validators.md). - `options`: + `placeholder`: (RENOUNCED) The placeholder for the field. + `disableonEdit`: When the form is in edit mode, the field becomes unable to be edited. The default value is false. diff --git a/splunk_add_on_ucc_framework/schema/schema.json b/splunk_add_on_ucc_framework/schema/schema.json index 37a515ab4..6a5394b8f 100644 --- a/splunk_add_on_ucc_framework/schema/schema.json +++ b/splunk_add_on_ucc_framework/schema/schema.json @@ -591,35 +591,8 @@ "encrypted": { "$ref": "#/definitions/encrypted" }, - "validators": { - "type": "array", - "description": "It is used to validate the values of fields using various validators.", - "minItems": 1, - "items": { - "anyOf": [ - { - "$ref": "#/definitions/NumberValidator" - }, - { - "$ref": "#/definitions/StringValidator" - }, - { - "$ref": "#/definitions/RegexValidator" - }, - { - "$ref": "#/definitions/EmailValidator" - }, - { - "$ref": "#/definitions/Ipv4Validator" - }, - { - "$ref": "#/definitions/UrlValidator" - }, - { - "$ref": "#/definitions/DateValidator" - } - ] - } + "validators":{ + "$ref": "#/definitions/AnyValidator" }, "options": { "type": "object", @@ -2086,6 +2059,9 @@ }, "modifyFieldsOnValue": { "$ref": "#/definitions/modifyFieldsOnValue" + }, + "validators":{ + "$ref": "#/definitions/AnyValidator" } }, "additionalProperties": false @@ -2323,6 +2299,36 @@ ], "additionalProperties": false }, + "AnyValidator":{ + "type": "array", + "description": "It is used to validate the values of fields using various validators.", + "minItems": 1, + "items": { + "anyOf": [ + { + "$ref": "#/definitions/NumberValidator" + }, + { + "$ref": "#/definitions/StringValidator" + }, + { + "$ref": "#/definitions/RegexValidator" + }, + { + "$ref": "#/definitions/EmailValidator" + }, + { + "$ref": "#/definitions/Ipv4Validator" + }, + { + "$ref": "#/definitions/UrlValidator" + }, + { + "$ref": "#/definitions/DateValidator" + } + ] + } + }, "ValueLabelPair": { "type": "object", "description": "Options with a label and a value.", diff --git a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json index 0336f633a..96e24cfd5 100644 --- a/tests/testdata/test_addons/package_global_config_everything/globalConfig.json +++ b/tests/testdata/test_addons/package_global_config_everything/globalConfig.json @@ -275,12 +275,25 @@ { "oauth_field": "some_text", "label": "Disabled on edit for oauth", - "help": "Enter text for field disabled on edit", + "help": "Enter text for field disabled on edit, no special characters allowed", "field": "basic_oauth_text", "required": false, "options": { "disableonEdit": true - } + }, + "validators": [ + { + "type": "string", + "errorMsg": "Max host length is 4096", + "minLength": 10, + "maxLength": 4096 + }, + { + "type": "regex", + "errorMsg": "do not use special characters", + "pattern": "^[a-zA-Z]\\w*$" + } + ] } ], "oauth": [ @@ -1622,10 +1635,10 @@ "meta": { "name": "Splunk_TA_UCCExample", "restRoot": "splunk_ta_uccexample", - "version": "5.49.0Rcc63ee532", + "version": "5.50.0Rb2c34d2c8", "displayName": "Splunk UCC test Add-on", "schemaVersion": "0.0.8", - "_uccVersion": "5.49.0", + "_uccVersion": "5.50.0", "supportedThemes": [ "light", "dark" diff --git a/ui/src/types/globalConfig/entities.ts b/ui/src/types/globalConfig/entities.ts index 58fa0f228..0e3f6bb84 100644 --- a/ui/src/types/globalConfig/entities.ts +++ b/ui/src/types/globalConfig/entities.ts @@ -257,6 +257,7 @@ export const OAuthFields = z.object({ }) .optional(), modifyFieldsOnValue: ModifyFieldsOnValue, + validators: AllValidators.optional(), }); export const OAuthEntity = CommonEditableEntityFields.extend({