validate hours and minutes

Hello,

I'm validating two fields:
the first field is the hours and the second the minutes.


I need the hours to be greater than or equal to 9 and the minutes less than or equal to 59

validations: {
if(
and(
local!hours >=9,
or(between(local!minute<>0,local!minute>59)),
"The values ​​in this field must be between 0 and 59"
),
"The effective hours can not be more than 9",
{}
)
}

thanks

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Firstly, I don't think we have any between() function available in Appian. And for the validations,you can add field validations in respective fields. Like in hours,

    a!integerField(
    
    label:"Hour",
    
    validations:{if (local!hours>9,"Message","")})

    Similarly add validations in minute field like 

    a!integerField(
    
    label:"Minutes",
    
    validations:{if (and(local!minutes>0,local!minutes<59),"","Message")})

    Hope this helps.

  • load(
      local!hours,
      local!minute,
      {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!integerField(
                  label: "Hours",
                  value: local!hours,
                  saveInto: local!hours,
                  validations: if(
                    isnull(
                      local!hours
                    ),
                    {},
                    if(
                      local!hours >= 9,
                      "The effective hours can not be more than 9",
                      {}
                    )
                  )
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!integerField(
                  label: "Minute",
                  value: local!minute,
                  saveInto: local!minute,
                  validations: if(
                    isnull(
                      local!minute
                    ),
                    {},
                    if(
                      local!minute >= 60,
                      "The values in this field must be between 0 and 59",
                      {}
                    )
                  )
                )
              }
            )
          }
        )
      }
    )