ch.Condition (Class)

Documentation updated on Fri Jul 06 2012, generated by JsDoc Toolkit.

Overview

Condition utility.

View source on GitHub

Returns

itself

Use

Create a new condition object with patt.

var widget = ch.condition({
    "name": "string",
    "patt": /^([a-zA-Z\u00C0-\u00C4\u00C8-\u00CF\u00D2-\u00D6\u00D9-\u00DC\u00E0-\u00E4\u00E8-\u00EF\u00F2-\u00F6\u00E9-\u00FC\u00C7\u00E7\s]*)$/,
    "message": "Some message here!"
});

Create a new condition object with expr.

var widget = ch.condition({
    "name": "maxLength",
    "patt": function(a,b) { return a.length <= b },
    "message": "Some message here!",
    "value": 4
});

Create a new condition object with func.

var widget = ch.condition({
    "name": "custom",
    "patt": function (value) { 
        if (value === "ChicoUI") {

            // Some code here!

            return true;
        };

        return false;
    },
    "message": "Your message here!"
});

Configuration

The following options lets you create a customized ch.Condition:

  • condition: Object Object with configuration properties.
  • condition.name: String
  • condition.patt: Object
  • condition.expr: Function
  • condition.func: Function
  • condition.value: Number || String
  • condition.message: String Validation message

Returns

Properties

message

Message defined for this condition

string

name

Flag that let you know if the all conditions are enabled or not.

string

Methods

disable()

Turn off condition.

Returns

  • itself
enable()

Turn on condition.

Returns

  • itself
test()

Run configured condition

Returns

  • boolean