Skip to main content
November 3, 2021
Question

Placing OR condition

  • November 3, 2021
  • 5 replies
  • 0 views

Hi,

How can I use an OR condition inside the validation.

Basically, I would like to post a message if the age is less than 1 or greater than 100

a!integerField(
label: "Age",
labelPosition: "ABOVE",
value: ri!employee2.age,
saveInto: ri!employee2.age,
refreshAfter: "UNFOCUS",
validations: if(
ri!employee2.age < 1 |or ,
"You must enter proper age",
""
)

5 replies

acaciob0002
November 3, 2021

Hi there,

Is this what you are looking for?

a!integerField(
  label: "Age",
  labelPosition: "ABOVE",
  value: ri!employee2.age,
  saveInto: ri!employee2.age,
  refreshAfter: "UNFOCUS",
  validations: if(
    or(
      tointeger(index(ri!employee2, "age", null)) < 1,
      tointeger(index(ri!employee2, "age", null)) > 100
    ),
    "You must enter proper age",
    ""
  )
)

Acacio B.

November 3, 2021

Thank you. This works for me.

I would like to know why you have used "index". Can't we just use like below.

Any comments from your end will be appreciated. Thanks in advance.

validations: if(
or(
tointeger(ri!employee2.age) < 1,
tointeger(ri!employee2.age)  > 100
),
"You must enter proper age",
""
)

acaciob0002
November 3, 2021

Great that works.

Using index() you can handler the nulls and avoid some errors, I normally use but you can check if it is necessary in your case.

Regards,

Acacio B