function validatePattern(updatedPattern) {
  var isValid = true;
  var fps = updatedPattern.Pattern_FP;
  var fpNames = [];
  for (var i = 0; i < fps.length; i++) {
    var fp = fps[i];
    var fpName = fp.Pattern_FP_ID;
    if (fpNames.indexOf(fpName) > -1) {
      alert("All functional processes must be unique.");
      isValid = false;
      break;
    }
    fpNames.push(fpName);
    var dgdms = fp.Pattern_DGDM;
    if (dgdms.length < 1) {
      alert("A functional process must contain at least one data group.");
      isValid = false;
      break;
    }
    var nMovements = 0;
    for (var j = 0; j < dgdms.length; j++) {
      var dgdm = dgdms[j];
      nMovements += dgdm.Pattern_DM_E + dgdm.Pattern_DM_X + dgdm.Pattern_DM_R + dgdm.Pattern_DM_W;
    }
    if (nMovements < 1) {
      alert("A functional process must contain at least one data movement.");
      isValid = false;
      break;
    }
  }
  updatedPattern.isAValidPattern = isValid;
}
/*
Validation rules
  - A FP must have at least 1 DG and at least 1 DM
  - A FP is unique in the pattern
*/
Validation rules
A FP must have at least 1 DG and at least 1 DM
A FP is unique in the pattern
Validation rules A FP must have at least 1 DG and at least 1 DM A FP is unique in the pattern
function validatePattern(updatedPattern) {
  var isValid = true;
  var fps = updatedPattern.Pattern_FP;
  var fpNames = [];
  for (var i = 0; i < fps.length; i++) {
    var fp = fps[i];
    var fpName = fp.Pattern_FP_ID;
    if (fpNames.indexOf(fpName) > -1) {
      alert("All functional processes must be unique.");
      isValid = false;
      break;
    }
    fpNames.push(fpName);
    var dgdms = fp.Pattern_DGDM;
    if (dgdms.length < 1) {
      alert("A functional process must contain at least one data group.");
      isValid = false;
      break;
    }
    var nMovements = 0;
    for (var j = 0; j < dgdms.length; j++) {
      var dgdm = dgdms[j];
      nMovements += dgdm.Pattern_DM_E + dgdm.Pattern_DM_X + dgdm.Pattern_DM_R + dgdm.Pattern_DM_W;
    }
    if (nMovements < 1) {
      alert("A functional process must contain at least one data movement.");
      isValid = false;
      break;
    }
  }
  updatedPattern.isAValidPattern = isValid;
}
function validatePattern ( updatedPattern ) { var isValid = true ; var fps = updatedPattern . Pattern_FP ; var fpNames = [ ] ; for ( var i = 0 ; i < fps . length ; i ++ ) { var fp = fps [ i ] ; var fpName = fp . Pattern_FP_ID ; if ( fpNames . indexOf ( fpName ) > - 1 ) { alert ( "All functional processes must be unique." ) ; isValid = false ; break ; } fpNames . push ( fpName ) ; var dgdms = fp . Pattern_DGDM ; if ( dgdms . length < 1 ) { alert ( "A functional process must contain at least one data group." ) ; isValid = false ; break ; } var nMovements = 0 ; for ( var j = 0 ; j < dgdms . length ; j ++ ) { var dgdm = dgdms [ j ] ; nMovements += dgdm . Pattern_DM_E + dgdm . Pattern_DM_X + dgdm . Pattern_DM_R + dgdm . Pattern_DM_W ; } if ( nMovements < 1 ) { alert ( "A functional process must contain at least one data movement." ) ; isValid = false ; break ; } } updatedPattern . isAValidPattern = isValid ; }
Validation rules
 A FP must have at least 1 DG and at least 1 DM
 A FP is unique in the pattern
Validation rules A FP must have at least 1 DG and at least 1 DM A FP is unique in the pattern