-2

i'm reading about a ui framework (quasar) and they have a component (q-input) that have a prop(rules) of type array of function/strings

<q-input
        filled
        type="number"
        v-model="age"
        label="Your age *"
        lazy-rules
        :rules="[
          val => val !== null && val !== '' || 'Please type your age',
          val => val > 0 && val < 100 || 'Please type a real age'
        ]"
      />

what i don't understand is what the purpose of the characters (||) that they use to separate function and strings

CSharp-n
  • 140
  • 7
  • It isn't separating functions or strings. It is part of the logic of the function. `val !== null && val !== '' || 'Please type your age'` is the expression that will be evaluated, in terms of `val`, when that rule is used (`val` being the name for the thing that is validated by the rule). `||` here has the same meaning that it would anywhere else in the language used to write the rules - I'm not familiar with Vue or Quasar, but I assume that's supposed to be Javascript. – Karl Knechtel May 13 '22 at 14:57
  • https://quasar.dev/vue-components/input#validation – deceze May 13 '22 at 15:03

0 Answers0