Semantic-ui: [Form][Validation] Validate a number range?

Created on 19 Jul 2016  路  2Comments  路  Source: Semantic-Org/Semantic-UI

We can validate an integer range with integer[0..10] but we can't seem validate a number range as in number[0..10]. Is there a workaround?

Most helpful comment

I ended up satisfying coverage with two separate rules, the semantic number validator and a custom validator that checks if the input value is between two given values.

Attaching custom rules is pretty easy:

$.fn.form.settings.rules.greaterThan = function (inputValue, validationValue) {
    return inputValue > validationValue;
}

and to reference it:

rules: [
  {
    type: 'number',
    prompt: 'A valid number is required for: {name}',
  },
  {
    type: 'greaterThan[validationValue]',
    prompt: 'Prompt Value',
  },
],

All 2 comments

Did you find anything?

I ended up satisfying coverage with two separate rules, the semantic number validator and a custom validator that checks if the input value is between two given values.

Attaching custom rules is pretty easy:

$.fn.form.settings.rules.greaterThan = function (inputValue, validationValue) {
    return inputValue > validationValue;
}

and to reference it:

rules: [
  {
    type: 'number',
    prompt: 'A valid number is required for: {name}',
  },
  {
    type: 'greaterThan[validationValue]',
    prompt: 'Prompt Value',
  },
],
Was this page helpful?
0 / 5 - 0 ratings