Validate a field which accept 0,1,2,3,4,5,6

Certified Senior Developer

HI Team,

I stuck on feild validation which will accept only below combination:

it can be 

0,1,2,3,4,5,6

or 0,1 or 1,2 combinations with all numbers or it can be only value which is less than 6 

I am able to achieve with below code

a!isNullOrEmpty(
stripwith(
ri!GBL_AutoCaseRunTimeConfig.config_value,
"0123456,"
)
)

but 

if user enters like 1,2,,,,,,, or 1,2,25 this is accepting , because it is under stripwith value i have added,  how can we validate ?

might be to use split with comma and use contains functions and also how we can remove comma at last ?

Any good suggestions ?

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Are you saying the user enters a text value of like "0,1" or "0,1,2", ... "0,1,2,3,4,5,6", and those permutations?  It's a little unclear what the delineation is here between valid/expected inputs and invalid ones.

    Also: is it order independent?  Accepts multiple values? Etc?  You didn't specify, but if these are constraints we aren't worried about, then the following might work:

    a!localVariables(
      local!input,
      
      local!validSet: {1, 2, 3, 4, 5, 6, 0},
      
      a!textField(
        value: local!input,
        saveinto: local!input,
        
        validations: {
          if(
            and(
              a!isNotNullOrEmpty(local!input),
              or(
                a!forEach(
                  split(local!input, ","),
                  or(
                    fv!item <> tostring(tointeger(fv!item)),
                    not(contains(local!validSet, tointeger(fv!item)))
                  )
                )
              )
            ),
            "Invalid Entry",
            {}
          )
        }
      )
    )

    Valid:

    Invalid:

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    I have always wondered how do you capture screenshots like this.

  • 0
    Certified Lead Developer
    in reply to Harshit Bumb (Appyzie)

    I use a freeware tool called Greenshot - i have it mapped to my "printscreen" key (key bindings are fully editable), where the keypress immediately brings up a region-selection tool

    and after selecting the region i want, it immediately opens a compact editor, with quick access to features like drawing, highlighting, obfuscating (blur or pixellate), adding a clean border or "torn edge" border...

    (you probably don't need to guess which one i like doing more often, lol...)

    And when done editing, you just press "copy" if you don't want to mess with saving the file somewhere (though that's also made easy), and can paste directly here.

    The one thing it doesn't do that I sometimes miss is small video snippets.  But I like the rest of it well enough that I really can't complain.

Reply
  • 0
    Certified Lead Developer
    in reply to Harshit Bumb (Appyzie)

    I use a freeware tool called Greenshot - i have it mapped to my "printscreen" key (key bindings are fully editable), where the keypress immediately brings up a region-selection tool

    and after selecting the region i want, it immediately opens a compact editor, with quick access to features like drawing, highlighting, obfuscating (blur or pixellate), adding a clean border or "torn edge" border...

    (you probably don't need to guess which one i like doing more often, lol...)

    And when done editing, you just press "copy" if you don't want to mess with saving the file somewhere (though that's also made easy), and can paste directly here.

    The one thing it doesn't do that I sometimes miss is small video snippets.  But I like the rest of it well enough that I really can't complain.

Children
No Data