Validators

checked

The value must be a truthy value. To be used with checkboxes that require a user to check them (i.e. accept a service agreement).

usage

  
self.agreeToTerms = ko.observableArray().extend({
    checked: { params: true, message: "must agree to terms" }
});
  

options

Name Type Default Description
message HTML String You must agree. HTML string to display for invalid values

ipAddress

The value must be a valid IPv4 Address. IPv6 is currently not supported by the control portal so we don't have a validator for it.

usage

  
self.agreeToTerms = ko.observableArray().extend({
    ipAddress: { params: true, message: "must be a IPv4 Address" }
});
  

options

Name Type Default Description
message HTML String Please enter a valid IPv4 address (ex: 10.189.12.0). HTML string to display for invalid values

ipAddressCidr

The value must be a valid IPv4 CIDR

usage

  
self.agreeToTerms = ko.observableArray().extend({
    ipAddressCidr: { params: true, message: "must be a IPv4 Cidr" }
});
  

options

Name Type Default Description
message HTML String Please enter a valid IPv4 CIDR (ex: 10.189.12.0/24). HTML string to display for invalid values

notEmpty

Checks for a length property and makes sure it is greater than 0. This can be used with a checkbox list to make sure atleast one or more items is selected.

usage

  
self.password = ko.observableArray().extend({
    notEmpty: { params: true, message: "select one or more" }
});
  

options

Name Type Default Description
message HTML String Must not be empty HTML string to display for invalid values

passwordStrength

Test for lower, upper, number, special characters as well as password length. The passwordStrength validator should be used in conjuction with the passwordStrength widget.

Strength is caluculated on the following basis. If the length is less than 8 the strength is 0. If there are less than 3 characters then the strength is 1. If the character type count is 3 and the length is 8 then the strength is 2. If the character type count is 3 and the length is 9 then the strength is 3. If it makes it through all of those then the strength is 4.

usage

  
self.password = ko.observable().extend({
    passwordStrength: { requiredStrength: 4, dissallowedCharacters: "[}" }
});
  

options

Name Type Default Description
requiredStrength number (0-4) 3 calculated based on character types and length
dissallowedCharacters String none a string containing disallowed characters
message HTML String depends on the strength HTML string to display for invalid values

uri

Must be a valid uri, with an option to specify the scheme that it must adhere to.

usage

  
self.agreeToTerms = ko.observableArray().extend({
    uri: { scheme: "https" }
});
  

options

Name Type Default Description
scheme String undefined a scheme that the uri must adhere to to be valid
message HTML String Please enter a valid uri HTML string to display for invalid values
anchor link to top of page