RE: Validation

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?

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    in reply to JS0001

      Oh you mean you want validation for more than 3?

     5.6678:1 :- Validation Should Show
     5.667:1   :- Validation Shouldn't show

    Is that what you are expecting?

  • 0
    Certified Senior Developer
    in reply to JS0001

     
    Try this and let me know if that works for you

    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(
              like(ri!inputValue_txt, "*:1"),
              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]
            ),
            ""
          )
        )
      )
    )

  • I am calculating for value type=Ratio:1 , Please provide calculation for ratio:1 type. I have sent code above.Valuetype is cons!CR_APP_FIN_COV_VALUE_TYPES[2] not cons!CR_APP_FIN_COV_VALUE_TYPES[3].

  • 0
    Certified Senior Developer
    in reply to JS0001

      
    You mean
    cons!CR_APP_FIN_COV_VALUE_TYPES[2] holds "Ratio:1"
    cons!CR_APP_FIN_COV_VALUE_TYPES[1] holds "Ratio".

  • 0
    Certified Senior Developer
    in reply to JS0001

    Check code as I changed based on above understanding.
    Let me know if that works for you.

    if(
      ri!valueType_txt =cons!CR_APP_FIN_COV_VALUE_TYPES[1],
      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 = cons!CR_APP_FIN_COV_VALUE_TYPES[2],
        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(
                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 = 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, Shubham, it worked,Thanks for that Can I get one more suggestion? For the value type= cons!CR_APP_FIN_COV_VALUE_TYPES[3] or Amount field in the above code, Type of that column has to take input has integer value, Now the field is accepting decimal values. How can we make changes to the existing code?

  • 0
    Certified Senior Developer
    in reply to JS0001

      
    Try this code and let me know that works for you.
    Analyse the code for future understanding.

    if(
      ri!valueType_txt =cons!CR_APP_FIN_COV_VALUE_TYPES[1],
      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 = cons!CR_APP_FIN_COV_VALUE_TYPES[2],
        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(
              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 = cons!CR_APP_FIN_COV_VALUE_TYPES[3],
          if(
            len(cleanwith(ri!inputValue_txt, ".")) = 0,
            if(
              len(ri!inputValue_txt) < 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]
            ),
            ""
          )
        )
      )
    )