validateOptions: function()

in aws-ecs-server/src/main/resources/buildServerResources/ecsSettings.js [341:396]


    validateOptions: function (options){
        var isValid = true;

        var validators = {
            launchType : function () {
                var launchType = this._image['launchType'];
                if (!launchType || launchType === '' || launchType === undefined) {
                    this.addOptionError('notSelected', 'launchType');
                    isValid = false;
                }
            }.bind(this),

            taskDefinition : function () {
                if (!this._image['taskDefinition']) {
                    this.addOptionError('required', 'taskDefinition');
                    isValid = false;
                }
            }.bind(this),

            maxInstances: function () {
                var maxInstances = this._image['maxInstances'];
                if (maxInstances && (!$j.isNumeric(maxInstances) || maxInstances < 0 )) {
                    this.addOptionError('nonNegative', 'maxInstances');
                    isValid = false;
                }
            }.bind(this),

            cpuReservationLimit: function () {
                var cpuReservationLimit = this._image['cpuReservationLimit'];
                if (cpuReservationLimit && (!$j.isNumeric(cpuReservationLimit) || cpuReservationLimit < 0 || cpuReservationLimit > 100 )) {
                    this.addOptionError('nonPercentile', 'cpuReservationLimit');
                    isValid = false;
                }
            }.bind(this),

            agent_pool_id : function () {
                var agentPoolId = this._image['agent_pool_id'];
                if (!agentPoolId || agentPoolId === '' || agentPoolId === undefined) {
                    this.addOptionError('notSelected', 'agent_pool_id');
                    isValid = false;
                }
            }.bind(this)
        };

        if (options && ! $j.isArray(options)) {
            options = [options];
        }

        this.clearOptionsErrors(options);

        (options || this._dataKeys).forEach(function(option) {
            if(validators[option]) validators[option]();
        });

        return isValid;
    },