function RuleTypeMagnitudeWidgetType(id, value, min, max)
{
    this.value    = null;
    this.min      = null;
    this.max      = null;
    this.widgetid = '';
    
    if (typeof value !== 'undefined' && value !== null) {
        this.value = value;
    }

    if (typeof min !== 'undefined' && min !== null && min !== '') {
        this.min = Number(min);
    }

    if (typeof max !== 'undefined' && max !== null && max !== '') {
        this.max = Number(max);
    }

}

RuleTypeMagnitudeWidgetType.prototype = {
    reset: function()
    {
        this.simpleResult = false;
        this.widget       = null;
        this.value        = null;
        this.server       = true;
        this.client       = true;
        this.errors       = [];

    },

    setValue: function(val)
    {
        this.value = val;

    },

    setWidgetid: function(wid)
    {
        this.widgetid = wid;

    },

    validate: function()
    {
        var val = Number(this.value);

        // Not greater than.
        if (this.min === null && this.max !== null) {
            if (val > this.max) {
                return false;
            }
        }

        // Not less than.
        if (this.min !== null && this.max === null) {
            if (val < this.min) {
                return false;
            }
        }

        // Check if value is within specified range.
        if (this.min !== null && this.max !== null) {
            if (this.min >= this.max) {
                // Incorrect logic, skip this check.
                return true;
            }

            if (val < this.min || val > this.max) {
                return false;
            }
        }

        return true;

    }

};
