Skip to main content
April 20, 2024
Question

RE: Validation

  • April 20, 2024
  • 18 replies
  • 0 views

if(
  ri!valueType_txt = "Ratio",
  if(
    and(
      like(ri!inputValue_txt, "*:*"),
      isnull(
        stripwith(ri!inputValue_txt, "1234567890:.")
      ),
      not(
        isnull(stripwith(ri!inputValue_txt, ":."))
      ),
      left(ri!inputValue_txt) <> ":",
      right(ri!inputValue_txt) <> ":"
    ),
    "",
    cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[1]
  ),
  if(
    ri!valueType_txt = "Ratio:1",
    if(
      and(
        like(ri!inputValue_txt, "*:1"),
        isnull(
          stripwith(ri!inputValue_txt, "1234567890:.")
        ),
        not(
          isnull(stripwith(ri!inputValue_txt, ":."))
        ),
        left(ri!inputValue_txt) <> ":",
        right(ri!inputValue_txt) <> ":"
      ),
      "",
      "Value is not in the format of m:1."
    ),
    if(
      ri!valueType_txt = cons!CR_APP_FIN_COV_VALUE_TYPES[3],
      if(
        and(
          len(
            stripwith(ri!inputValue_txt, "0123456789.")
          ) = 0,
          len(cleanwith(ri!inputValue_txt, ".")) < 2
        ),
        if(
          and(
            len(
              cleanwith(ri!inputValue_txt, "0123456789")
            ) < 15
          ),
          "",
          cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[3]
        ),
        cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[4]
      ),
      if(
        ri!valueType_txt = cons!CR_APP_FIN_COV_VALUE_TYPES[4],
        if(
          and(
            len(
              stripwith(ri!inputValue_txt, "0123456789.%")
            ) = 0,
            len(cleanwith(ri!inputValue_txt, ".")) < 2
          ),
          "",
          cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[4]
        ),
        ""
      )
    )
  )
)

Hi Everyone, I am looking for a solution related to when valueType= "Ratio:1", then the upto 3 decimals on left side:1 ,need to restrict values which are entered more than 4 decimals in left only, How Can I do that,Can anyone help to do that?

    18 replies

    karthikk538
    April 20, 2024

    Hi JS,

    Over all as far i understand , after the ratio in the provided text by user, you should allow only three characters after ratio, if its more than three you should show an message right?

    see if the below logic works

    a!localVariables(
    
    local!splitValues:split("ABC:12323",":"),
    
    
    
    if(len(index(local!splitValues,2,""))>3,"Greater than three","Good")
    
    )

    if this is not what you are expecting, can you help with user input and what validation you are trying to perform.

    April 20, 2024

    not after ratio,before ratio,ok let me give example to u, value = 2.655:1

    stefanhelzle0001
    Brainy
    April 20, 2024

    I have a hard time understanding your explanation. Can you help me?

    April 20, 2024

    ok, So we have value type in ui has ratio:1 type that means user can enter value has 5.6678435.1 format ,but instead of entering more that 3 decimals ,we need to restrict up to 3 decimals only. I hope now this sentence understandable.

    shubhama926776
    Brainy
    April 20, 2024
    5.6678435.1 format

    You mean 5.6678435:1

    शुभम्
    shubhama926776
    Brainy
    April 20, 2024

    Hello [mention:ef0fbf994c9643cd84ee894e18f03e86:e9ed411860ed4f2ba0265705b8793d05] 
    I made changes to your provided code to meet your requirement. Validate once and let me know if that works for you.
    This ensures only values with a maximum of 3 decimals on the left side are allowed.

    if(
      ri!valueType_txt = "Ratio",
      if(
        and(
          like(ri!inputValue_txt, "*:*"),
          isnull(
            stripwith(ri!inputValue_txt, "1234567890:.")
          ),
          not(
            isnull(stripwith(ri!inputValue_txt, ":."))
          ),
          left(ri!inputValue_txt) <> ":",
          right(ri!inputValue_txt) <> ":"
        ),
        "",
        cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[1]
      ),
      if(
        ri!valueType_txt = "Ratio:1",
        if(
          and(
            like(ri!inputValue_txt, "*:1"),
            isnull(
              stripwith(ri!inputValue_txt, "1234567890:.")
            ),
            not(
              isnull(stripwith(ri!inputValue_txt, ":."))
            ),
            left(ri!inputValue_txt) <> ":",
            right(ri!inputValue_txt) <> ":"
          ),
          "",
          "Value is not in the format of m:1."
        ),
        if(
          ri!valueType_txt = cons!CR_APP_FIN_COV_VALUE_TYPES[3],
          if(
            and(
              len(
                stripwith(ri!inputValue_txt, "0123456789.")
              ) = 0,
              len(
                index(
                  split(
                    left(
                      ri!inputValue_txt,
                      find(":", ri!inputValue_txt) - 1
                    ),
                    "."
                  ),
                  2,
                  {}
                )
              ) <= 3,
            ),
            if(
              and(
                len(
                  cleanwith(ri!inputValue_txt, "0123456789")
                ) < 15
              ),
              "",
              cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[3]
            ),
            cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[4]
          ),
          if(
            ri!valueType_txt = cons!CR_APP_FIN_COV_VALUE_TYPES[4],
            if(
              and(
                len(
                  stripwith(ri!inputValue_txt, "0123456789.%")
                ) = 0,
                len(cleanwith(ri!inputValue_txt, ".")) < 2
              ),
              "",
              cons!CR_APP_COV_THRESHOLD_VALIDATION_MSG[4]
            ),
            ""
          )
        )
      )
    )

    शुभम्
    April 21, 2024

    Hi ,I have tried with this code for the  value Type=Ratio:1 type, Coz I needed  validation for that value type(Ratio:1), I am getting this validation in ui

    if(
      ri!valueType_txt ="Ratio",
      if(
        and(
          like(ri!inputValue_txt, "*:*"),
          isnull(
            stripwith(ri!inputValue_txt, "1234567890:.")
          ),
          not(
            isnull(stripwith(ri!inputValue_txt, ":."))
          ),
          left(ri!inputValue_txt) <> ":",
          right(ri!inputValue_txt) <> ":"
        ),
        "",
        "Value is not in the format of m:n."
      ),
      if(
        ri!valueType_txt = "Ratio:1",
        if(
          and(
            like(ri!inputValue_txt, "*:1"),
            isnull(
              stripwith(ri!inputValue_txt, "1234567890:.")
            ),
            not(
              isnull(stripwith(ri!inputValue_txt, ":."))
            ),
            left(ri!inputValue_txt) <> ":",
            right(ri!inputValue_txt) <> ":",
            len(
              stripwith(ri!inputValue_txt, "0123456789.")
            ) = 0,
            len(
              index(
                split(
                  left(
                    ri!inputValue_txt,
                    find(":", ri!inputValue_txt) - 1
                  ),
                  "."
                ),
                2,
                {}
              )
            ) <= 3,
            
          ),
          "",
          "Value is not in the format of m:1."
        ),
        if(
          ri!valueType_txt = "Amount",
          if(
            and(
              len(
                stripwith(ri!inputValue_txt, "0123456789.")
              ) = 0,
              len(cleanwith(ri!inputValue_txt, ".")) < 2
            ),
            if(
              and(
                len(
                  cleanwith(ri!inputValue_txt, "0123456789")
                ) < 15
              ),
              "",
              "Value cannot be more than 14 digit numbers."
            ),
            "Invalid value entered."
          ),
          if(
            ri!valueType_txt = "Percentage",
            if(
              and(
                len(
                  stripwith(ri!inputValue_txt, "0123456789.%")
                ) = 0,
                len(cleanwith(ri!inputValue_txt, ".")) < 2
              ),
              "",
              "Invalid value entered."
            ),
            ""
          )
        )
      )
    )

    shubhama926776
    Brainy
    April 21, 2024

    As you mentioned earlier
    user can enter value as 5.6678435:1 format ,but instead of entering more that 3 decimals ,we need to restrict up to 3 decimals only.
    That what code is doing. It's restricting user using validation.

    [mention:ef0fbf994c9643cd84ee894e18f03e86:e9ed411860ed4f2ba0265705b8793d05] Am i missing something?

    शुभम्