diff --git a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js
index 916f724..6ac6d75 100644
--- a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js
+++ b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js
@@ -13,133 +13,185 @@
  * or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
-import {actionTypes} from './JSONSchemaReducerConstants.js';
+import { actionTypes } from './JSONSchemaReducerConstants.js';
 import Validator from 'nfvo-utils/Validator.js';
 import JSONSchema from 'nfvo-utils/json/JSONSchema.js';
 import JSONPointer from 'nfvo-utils/json/JSONPointer.js';
 import forOwn from 'lodash/forOwn.js';
 import isArray from 'lodash/isArray.js';
 
-
 function flattenData(data, result, pointer = '') {
-	let newPointer = pointer;
-	if (typeof data === 'object' && !isArray(data)) {
-		for (let i in data) {
-			newPointer = newPointer ? newPointer + '/' + i : i;
-			flattenData(data[i], result, newPointer);
-			newPointer = pointer;
-		}
-	} else {
-		result[newPointer] = data;
-	}
+    let newPointer = pointer;
+    if (typeof data === 'object' && !isArray(data)) {
+        for (let i in data) {
+            newPointer = newPointer ? newPointer + '/' + i : i;
+            flattenData(data[i], result, newPointer);
+            newPointer = pointer;
+        }
+    } else {
+        result[newPointer] = data;
+    }
 }
 
-function updateSchemaDataAndValidateReducer (state = {}, action, questionnaireName) {
-	let genericFieldInfoClone;
-	switch (action.type) {
-		case actionTypes.DATA_LOADED:
-			if (questionnaireName !== action.qName) {return {...state};}
-			const schema = action.payload.qschema;
-			let schemaLoader = new JSONSchema();
-			schemaLoader.setSchema(schema);
-			schemaLoader.setSupportedValidationFunctions(Object.keys(Validator.globalValidationFunctions));
-			let {genericFieldInfo} = schemaLoader.flattenSchema();
+function updateSchemaDataAndValidateReducer(
+    state = {},
+    action,
+    questionnaireName
+) {
+    let genericFieldInfoClone;
+    switch (action.type) {
+        case actionTypes.DATA_LOADED:
+            if (questionnaireName !== action.qName) {
+                return { ...state };
+            }
+            const schema = action.payload.qschema;
+            let schemaLoader = new JSONSchema();
+            schemaLoader.setSchema(schema);
+            schemaLoader.setSupportedValidationFunctions(
+                Object.keys(Validator.globalValidationFunctions)
+            );
+            let { genericFieldInfo } = schemaLoader.flattenSchema();
 
-			let data = action.payload.qdata;
-			let dataMap =  {};
-			flattenData(data, dataMap);
+            let data = action.payload.qdata;
+            let dataMap = {};
+            flattenData(data, dataMap);
 
-			return {
-				...state,
-				qdata: action.payload.qdata, // the original hierarchical data. to be used for submit and save
-				qgenericFieldInfo : genericFieldInfo, // information about the fields that the view will require and reducer will need, such as validations, enum to use, etc.
-				dataMap //  flattened schema data for ease of use
-			};
+            return {
+                ...state,
+                qdata: action.payload.qdata, // the original hierarchical data. to be used for submit and save
+                qgenericFieldInfo: genericFieldInfo, // information about the fields that the view will require and reducer will need, such as validations, enum to use, etc.
+                dataMap //  flattened schema data for ease of use
+            };
 
-		case actionTypes.DATA_CHANGED:
-			let changedData = action.deltaData;
-			if (questionnaireName !== action.qName)  {return {...state};}
+        case actionTypes.DATA_CHANGED:
+            let changedData = action.deltaData;
+            if (questionnaireName !== action.qName) {
+                return { ...state };
+            }
 
-			genericFieldInfoClone = {...state.qgenericFieldInfo};
-			let qDataClone = {...state.qdata};
-			let dataMapClone = {...state.dataMap};
+            genericFieldInfoClone = { ...state.qgenericFieldInfo };
+            let qDataClone = { ...state.qdata };
+            let dataMapClone = { ...state.dataMap };
 
-			forOwn(changedData,(value, key) => {
-				if (state.qgenericFieldInfo[key]) {
-					let result = Validator.validate(key, value, state.qgenericFieldInfo[key].validations, state, action.customValidations);
-					genericFieldInfoClone[key] = {...genericFieldInfoClone[key], isValid: result.isValid, errorText: result.errorText};
-					qDataClone = JSONPointer.setValue(state.qdata, '/' + key, value);
-					dataMapClone[key] = value;
-				}
-			});
+            forOwn(changedData, (value, key) => {
+                if (state.qgenericFieldInfo[key]) {
+                    let result = Validator.validate(
+                        key,
+                        value,
+                        state.qgenericFieldInfo[key].validations,
+                        state,
+                        action.customValidations
+                    );
+                    genericFieldInfoClone[key] = {
+                        ...genericFieldInfoClone[key],
+                        isValid: result.isValid,
+                        errorText: result.errorText
+                    };
+                    qDataClone = JSONPointer.setValue(
+                        state.qdata,
+                        '/' + key,
+                        value
+                    );
+                    dataMapClone[key] = value;
+                }
+            });
 
-			return {
-				...state,
-				qdata: qDataClone,
-				dataMap: dataMapClone,
-				qgenericFieldInfo: genericFieldInfoClone
-			};
+            return {
+                ...state,
+                qdata: qDataClone,
+                dataMap: dataMapClone,
+                qgenericFieldInfo: genericFieldInfoClone
+            };
 
-		case actionTypes.VALIDATE_DATA:
-			let specificFields = action.data;
-			if (questionnaireName !== action.qName)  {return {...state};}
-			genericFieldInfoClone = {...state.qgenericFieldInfo};
-			forOwn(specificFields,(value, key) => {
-				let result = Validator.validate(key, value, state.qgenericFieldInfo[key].validations, state, action.customValidations);
-				genericFieldInfoClone[key] = {...genericFieldInfoClone[key], isValid: result.isValid, errorText: result.errorText};
-			});
-			return {
-				...state,
-				formReady: null,
-				qgenericFieldInfo: genericFieldInfoClone
-			};
+        case actionTypes.VALIDATE_DATA:
+            let specificFields = action.data;
+            if (questionnaireName !== action.qName) {
+                return { ...state };
+            }
+            genericFieldInfoClone = { ...state.qgenericFieldInfo };
+            forOwn(specificFields, (value, key) => {
+                let result = Validator.validate(
+                    key,
+                    value,
+                    state.qgenericFieldInfo[key].validations,
+                    state,
+                    action.customValidations
+                );
+                genericFieldInfoClone[key] = {
+                    ...genericFieldInfoClone[key],
+                    isValid: result.isValid,
+                    errorText: result.errorText
+                };
+            });
+            return {
+                ...state,
+                formReady: null,
+                qgenericFieldInfo: genericFieldInfoClone
+            };
 
-		case actionTypes.VALIDATE_FORM:
-			if (questionnaireName !== action.qName)  {return {...state};}
-			genericFieldInfoClone = {...state.qgenericFieldInfo};
-			let formReady = true;
-			forOwn(state.qgenericFieldInfo,(value, key) => {
-				let val = state.dataMap[key] ? state.dataMap[key] : '';
-				let result = Validator.validate(key, val, state.qgenericFieldInfo[key].validations, state, action.customValidations);
-				genericFieldInfoClone[key] = {...genericFieldInfoClone[key], isValid: result.isValid, errorText: result.errorText};
-				if (!result.isValid) {
-					formReady = false;
-				}
-			});
-			return {
-				...state,
-				formReady,
-				qgenericFieldInfo: genericFieldInfoClone
-			};
+        case actionTypes.VALIDATE_FORM:
+            if (questionnaireName !== action.qName) {
+                return { ...state };
+            }
+            genericFieldInfoClone = { ...state.qgenericFieldInfo };
+            let formReady = true;
+            forOwn(state.qgenericFieldInfo, (value, key) => {
+                let val = state.dataMap[key] ? state.dataMap[key] : '';
+                let result = Validator.validate(
+                    key,
+                    val,
+                    state.qgenericFieldInfo[key].validations,
+                    state,
+                    action.customValidations
+                );
+                genericFieldInfoClone[key] = {
+                    ...genericFieldInfoClone[key],
+                    isValid: result.isValid,
+                    errorText: result.errorText
+                };
+                if (!result.isValid) {
+                    formReady = false;
+                }
+            });
+            return {
+                ...state,
+                formReady,
+                qgenericFieldInfo: genericFieldInfoClone
+            };
 
-		default:
-			return state;
-	}
-};
+        default:
+            return state;
+    }
+}
 
 export function createJSONSchemaReducer(questionnaireName) {
-	return (state = {}, action) => {
-		return updateSchemaDataAndValidateReducer(state, action, questionnaireName);
-	};
-};
+    return (state = {}, action) => {
+        return updateSchemaDataAndValidateReducer(
+            state,
+            action,
+            questionnaireName
+        );
+    };
+}
 
-export function createComposedJSONSchemaReducer(questionnaireName, additionalActionsReducer) {
-	return (state = {}, action) => {
-		if(action.type === actionTypes.VALIDATE_DATA ||
-			action.type === actionTypes.VALIDATE_FORM ||
-			action.type === actionTypes.DATA_CHANGED ||
-			action.type === actionTypes.DATA_LOADED
-		) {
-			return updateSchemaDataAndValidateReducer(state, action, questionnaireName);
-		} else {
-			return additionalActionsReducer(state, action);
-		}
-	};
-};
-
-
-
-
-
-
-
+export function createComposedJSONSchemaReducer(
+    questionnaireName,
+    additionalActionsReducer
+) {
+    return (state = {}, action) => {
+        if (
+            action.type === actionTypes.VALIDATE_DATA ||
+            action.type === actionTypes.VALIDATE_FORM ||
+            action.type === actionTypes.DATA_CHANGED ||
+            action.type === actionTypes.DATA_LOADED
+        ) {
+            return updateSchemaDataAndValidateReducer(
+                state,
+                action,
+                questionnaireName
+            );
+        } else {
+            return additionalActionsReducer(state, action);
+        }
+    };
+}
diff --git a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js
index 6007b87..439613d 100644
--- a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js
+++ b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js
@@ -16,8 +16,8 @@
 import keyMirror from 'nfvo-utils/KeyMirror.js';
 
 export const actionTypes = keyMirror({
-	DATA_LOADED: null,
-	DATA_CHANGED: null,
-	VALIDATE_FORM: null,
-	VALIDATE_DATA: null
+    DATA_LOADED: null,
+    DATA_CHANGED: null,
+    VALIDATE_FORM: null,
+    VALIDATE_DATA: null
 });
diff --git a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js
index 49f1e3d..3049770 100644
--- a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js
+++ b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js
@@ -13,89 +13,135 @@
  * or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
-import {actionTypes} from './PlainDataReducerConstants.js';
+import { actionTypes } from './PlainDataReducerConstants.js';
 import Validator from 'nfvo-utils/Validator.js';
 import forOwn from 'lodash/forOwn.js';
-import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx';
+import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx';
 
 function updateDataAndValidateReducer(state = {}, action) {
-	let genericFieldInfoCopy;
-	switch (action.type) {
-		case actionTypes.DATA_CHANGED:
-			let changed = action.deltaData;
-			if (!action.formName || (state.formName !== action.formName)) {return {...state};}
-			genericFieldInfoCopy = {...state.genericFieldInfo};
-			forOwn(changed,(value, key) => {
-				if (state.genericFieldInfo[key]) {
-					let result = Validator.validate(key, value, state.genericFieldInfo[key].validations, state, action.customValidations);
-					genericFieldInfoCopy[key] = {...genericFieldInfoCopy[key], isValid: result.isValid, errorText: result.errorText};
-				}
-			});
-			return {
-				...state,
-				formReady: null,
-				data: {
-					...state.data,
-					...action.deltaData
-				},
-				genericFieldInfo: genericFieldInfoCopy
-			};
-		case actionTypes.VALIDATE_FORM:
-			if (!action.formName || (state.formName !== action.formName)) {return {...state};}
-			genericFieldInfoCopy = {...state.genericFieldInfo};
-			let formReady = true;
-			forOwn(state.genericFieldInfo,(value, key) => {
-				let val = state.data && state.data[key] ? state.data[key] : '';
-				let result = Validator.validate(key, val, state.genericFieldInfo[key].validations, state, {});
-				if(val.choice !== undefined) {
-					result = Validator.validate(key, val.choice, state.genericFieldInfo[key].validations, state, {});
-				}
-				if(val.choice !== undefined && val.choice === optionInputOther.OTHER) {
-					result = Validator.validate(key, val.other, state.genericFieldInfo[key].validations, state, {});
-				}
-				genericFieldInfoCopy[key] = {...genericFieldInfoCopy[key], isValid: result.isValid, errorText: result.errorText};
-				if (!result.isValid) {
-					formReady = false;
-				}
-			});
-			return {
-				...state,
-				formReady,
-				genericFieldInfo: genericFieldInfoCopy
-			};
-		case actionTypes.VALIDATE_DATA:
-			let specificFields = action.data;
-			if (!action.formName || (state.formName !== action.formName)) {return {...state};}
-			genericFieldInfoCopy = {...state.genericFieldInfo};
-			forOwn(specificFields,(value, key) => {
-				let result = Validator.validate(key, value, state.genericFieldInfo[key].validations, state, action.customValidations);
-				genericFieldInfoCopy[key] = {...genericFieldInfoCopy[key], isValid: result.isValid, errorText: result.errorText};
-			});
-			return {
-				...state,
-				formReady: null,
-				genericFieldInfo: genericFieldInfoCopy
-			};
-		default:
-			return state;
-	}
-};
+    let genericFieldInfoCopy;
+    switch (action.type) {
+        case actionTypes.DATA_CHANGED:
+            let changed = action.deltaData;
+            if (!action.formName || state.formName !== action.formName) {
+                return { ...state };
+            }
+            genericFieldInfoCopy = { ...state.genericFieldInfo };
+            forOwn(changed, (value, key) => {
+                if (state.genericFieldInfo[key]) {
+                    let result = Validator.validate(
+                        key,
+                        value,
+                        state.genericFieldInfo[key].validations,
+                        state,
+                        action.customValidations
+                    );
+                    genericFieldInfoCopy[key] = {
+                        ...genericFieldInfoCopy[key],
+                        isValid: result.isValid,
+                        errorText: result.errorText
+                    };
+                }
+            });
+            return {
+                ...state,
+                formReady: null,
+                data: {
+                    ...state.data,
+                    ...action.deltaData
+                },
+                genericFieldInfo: genericFieldInfoCopy
+            };
+        case actionTypes.VALIDATE_FORM:
+            if (!action.formName || state.formName !== action.formName) {
+                return { ...state };
+            }
+            genericFieldInfoCopy = { ...state.genericFieldInfo };
+            let formReady = true;
+            forOwn(state.genericFieldInfo, (value, key) => {
+                let val = state.data && state.data[key] ? state.data[key] : '';
+                let result = Validator.validate(
+                    key,
+                    val,
+                    state.genericFieldInfo[key].validations,
+                    state,
+                    {}
+                );
+                if (val.choice !== undefined) {
+                    result = Validator.validate(
+                        key,
+                        val.choice,
+                        state.genericFieldInfo[key].validations,
+                        state,
+                        {}
+                    );
+                }
+                if (
+                    val.choice !== undefined &&
+                    val.choice === optionInputOther.OTHER
+                ) {
+                    result = Validator.validate(
+                        key,
+                        val.other,
+                        state.genericFieldInfo[key].validations,
+                        state,
+                        {}
+                    );
+                }
+                genericFieldInfoCopy[key] = {
+                    ...genericFieldInfoCopy[key],
+                    isValid: result.isValid,
+                    errorText: result.errorText
+                };
+                if (!result.isValid) {
+                    formReady = false;
+                }
+            });
+            return {
+                ...state,
+                formReady,
+                genericFieldInfo: genericFieldInfoCopy
+            };
+        case actionTypes.VALIDATE_DATA:
+            let specificFields = action.data;
+            if (!action.formName || state.formName !== action.formName) {
+                return { ...state };
+            }
+            genericFieldInfoCopy = { ...state.genericFieldInfo };
+            forOwn(specificFields, (value, key) => {
+                let result = Validator.validate(
+                    key,
+                    value,
+                    state.genericFieldInfo[key].validations,
+                    state,
+                    action.customValidations
+                );
+                genericFieldInfoCopy[key] = {
+                    ...genericFieldInfoCopy[key],
+                    isValid: result.isValid,
+                    errorText: result.errorText
+                };
+            });
+            return {
+                ...state,
+                formReady: null,
+                genericFieldInfo: genericFieldInfoCopy
+            };
+        default:
+            return state;
+    }
+}
 
 export function createPlainDataReducer(loadReducer) {
-	return (state = {}, action) => {
-		if(action.type === actionTypes.VALIDATE_DATA ||
-			action.type === actionTypes.VALIDATE_FORM ||
-			action.type === actionTypes.DATA_CHANGED
-		) {
-			return updateDataAndValidateReducer(state, action);
-		} else {
-			return loadReducer(state, action);
-		}
-	};
-};
-
-
-
-
-
-
+    return (state = {}, action) => {
+        if (
+            action.type === actionTypes.VALIDATE_DATA ||
+            action.type === actionTypes.VALIDATE_FORM ||
+            action.type === actionTypes.DATA_CHANGED
+        ) {
+            return updateDataAndValidateReducer(state, action);
+        } else {
+            return loadReducer(state, action);
+        }
+    };
+}
diff --git a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js
index 135361d..8c38483 100644
--- a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js
+++ b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js
@@ -16,7 +16,7 @@
 import keyMirror from 'nfvo-utils/KeyMirror.js';
 
 export const actionTypes = keyMirror({
-	DATA_CHANGED: null,
-	VALIDATE_FORM: null,
-	VALIDATE_DATA: null
+    DATA_CHANGED: null,
+    VALIDATE_FORM: null,
+    VALIDATE_DATA: null
 });
