export function validateAutoStop()

in src/Utils/CommonUtils.ts [228:250]


export function validateAutoStop(autoStop: any, isPipelineParam: boolean = false): ValidationModel {
    if(typeof autoStop != 'string'){
        if(isNullOrUndefined(autoStop.errorPercentage) || isNaN(autoStop.errorPercentage) || autoStop.errorPercentage > 100 || autoStop.errorPercentage < 0) {
            let errorMessage = isPipelineParam 
                                ? `The value "${autoStop.errorPercentage}" for errorPercentage of auto-stop criteria is invalid in the overrideParameters provided. The value should be valid decimal number from 0 to 100.`
                                : `The value "${autoStop.errorPercentage}" for errorPercentage of auto-stop criteria is invalid. The value should be valid decimal number from 0 to 100.`;
            return {valid : false, error : errorMessage};
        }
        if(isNullOrUndefined(autoStop.timeWindow) || isNaN(autoStop.timeWindow) || autoStop.timeWindow <= 0 || !Number.isInteger(autoStop.timeWindow)){
            let errorMessage = isPipelineParam
                                ? `The value "${autoStop.timeWindow}" for timeWindow of auto-stop criteria is invalid in the overrideParameters provided. The value should be valid integer greater than 0.`
                                : `The value "${autoStop.timeWindow}" for timeWindow of auto-stop criteria is invalid. The value should be valid integer greater than 0.`
            return {valid : false, error : errorMessage};
        }
    }
    else if(autoStop != autoStopDisable){
        let errorMessage = isPipelineParam
                            ? 'Invalid value for "autoStop" in the overrideParameters provided, for disabling auto stop use "autoStop: disable"'
                            : 'Invalid value for "autoStop", for disabling auto stop use "autoStop: disable"'
        return {valid : false, error : errorMessage};
    }
    return {valid : true, error : ""};
}