Reporting

How to validate multiple parameters in an alert action?

boz_8058
Explorer

Here is my restmap.conf

[validation:savedsearch]

# Check for empty feed
action.myApp= case('action.myApp' != "1", null(), 'action.myApp.param.feed' == "action.myApp.param.feed" OR 'action.myApp.param.feed' == "", "Feed cannot be empty.",  1==1, null())

# Check for empty instance
action.myApp= case('action.myApp' != "1", null(), 'action.myApp.param.instance' == "action.myApp.param.instance" OR 'action.myApp.param.instance' == "", "Instance cannot be empty.",  1==1, null())

# Check for SSL
action.myApp= case('action.myApp' != "1", null(), 'action.myApp.param.ssl' == "1" AND 'action.myApp.param.cert' == "action.myApp.param.cert", "Cert path cannot be empty when SSL checked.", 'action.myApp.param.ssl' == "1" AND 'action.myApp.param.cert' == "", "Cert path cannot be empty when SSL checked.",  1==1, null())

# Check for feed regex
action.myApp.param.feed = validate( match('action.myApp.param.feed', "^[A-Z0-9_-]{3,}$"), "Feed is invalid, see regex for detail.")

# Check for instance regex
action.myApp.param.instance = validate( match('action.myApp.param.instance', "^https?:\/\/([a-zA-Z]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):\d+([\/\w]*)?$"), "Instance is invalid, see regex for detail.")

Everything works as expected if I comment out the check for SSL line, however as soon as I uncomment that line, I can save the alert even if all of the fields have no values.

How can I get this to work?

action.myApp.param.ssl is a checkbox
action.myApp.param.cert is a string input

Labels (1)
0 Karma
1 Solution

harsmarvania57
Ultra Champion

Can you please try below

[validation:savedsearch]
action.myApp= case('action.myApp' != "1", null(), 'action.myApp.param.feed' == "action.myApp.param.feed" OR 'action.myApp.param.feed' == "", "Feed cannot be empty.", 'action.myApp.param.instance' == "action.myApp.param.instance" OR 'action.myApp.param.instance' == "", "Instance cannot be empty.", 'action.myApp.param.ssl' == "1" AND ('action.myApp.param.cert' == "action.myApp.param.cert" OR 'action.myApp.param.cert' == ""), "Cert path cannot be empty when SSL checked.", 1==1, null())

# Check for feed regex
action.myApp.param.feed = validate( match('action.myApp.param.feed', "^[A-Z0-9_-]{3,}$"), "Feed is invalid, see regex for detail.")

# Check for instance regex
action.myApp.param.instance = validate( match('action.myApp.param.instance', "^https?:\/\/([a-zA-Z]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):\d+([\/\w]*)?$"), "Instance is invalid, see regex for detail.")

View solution in original post

0 Karma

harsmarvania57
Ultra Champion

Can you please try below

[validation:savedsearch]
action.myApp= case('action.myApp' != "1", null(), 'action.myApp.param.feed' == "action.myApp.param.feed" OR 'action.myApp.param.feed' == "", "Feed cannot be empty.", 'action.myApp.param.instance' == "action.myApp.param.instance" OR 'action.myApp.param.instance' == "", "Instance cannot be empty.", 'action.myApp.param.ssl' == "1" AND ('action.myApp.param.cert' == "action.myApp.param.cert" OR 'action.myApp.param.cert' == ""), "Cert path cannot be empty when SSL checked.", 1==1, null())

# Check for feed regex
action.myApp.param.feed = validate( match('action.myApp.param.feed', "^[A-Z0-9_-]{3,}$"), "Feed is invalid, see regex for detail.")

# Check for instance regex
action.myApp.param.instance = validate( match('action.myApp.param.instance', "^https?:\/\/([a-zA-Z]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):\d+([\/\w]*)?$"), "Instance is invalid, see regex for detail.")
0 Karma

boz_8058
Explorer

Works, thank you

0 Karma

harsmarvania57
Ultra Champion

Glad to know that it worked.

0 Karma

harsmarvania57
Ultra Champion

Hi,

Can you please provide your html code for checkbox ?

0 Karma

boz_8058
Explorer

Here are both checkbox and cert path

         <div class="control-group">
            <label class="control-label" for="ssl">Send using SSL?</label>
            <div class="controls">
                <label class="checkbox" for="ssl">
                  <input id="ssl" type="checkbox" name="action.myApp.param.ssl" value="1" />
                </label>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="cert">Certificate Path</label>
            <div class="controls">
                <input type="text" class="input-xlarge" name="action.myApp.param.cert" id="cert"  placeholder="Full path to certificate" />
            </div>
        </div>
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...