JavaScript function: checkAllowedOption

Returns the next valid version number of a Configuration Management baseline group if there is only one valid version number available.

Syntax

lib.versionControl.checkAllowedOption( oldVersion, maxIncrement );

Arguments

The following arguments are valid for this function:

Name Data type Required Description
oldVersion String Yes This argument contains the previous version number.
maxIncrement Array Yes This argument contains an array of numbers representing the decimal value of the maximum number increments possible. For example, if maxIncrement equals [0,1,0] then there are ten possible increments permissible from versions 0.0.1 to 0.1.0.

Return values

A valid version number or the string more.

The function returns a valid version number if there is one and only one valid next version number. The function returns the string more if there is more than one valid next version number.

Description

This function is part of a system JavaScript and should not be directly modified.

This function returns the next valid version number of a Configuration Management baseline group if there is one and only one valid version number available. If there is more than one valid next version number then the function returns the string more.

Example

This example attempts to create the next valid version from two variables.

This example requires the following sample data:

  • A variable storing the old version number
  • A variable storing the maximum number of increments allowed
/* Use oldVersion to store the old version number as a string.
*  Use maxIncrement to store the maximum number of increments as an array. */
var oldVersion;
var maxIncrement = new Array();

/* Create a function to test the checkAllowedOption function */
function nextVersionTest( versionOld, increment )
{
 var nextVersion = lib.versionControl.checkAllowedOption( versionOld, increment );
 if ( nextVersion == "more" )
 {
  print( "Error. There is more than one valid next version number for " + versionOld
		+ ".\n");
  return versionOld
 }
 else
 {
  print( "Success. The next valid version number is " + nextVersion + ".\n" );
  return nextVersion
 }
}

/* Test a valid version number update */
print( "Testing checkAllowedOption...\n" );
oldVersion = "1.0";
maxIncrement = [0,1];
print( "The current version number is " + oldVersion + "." );
print( "The maximum allowed increment is " + maxIncrement + ".");
nextVersionTest( oldVersion, maxIncrement );

/* Test a valid version number update */
print( "Testing checkAllowedOption...\n" );
oldVersion = "0.9.9";
maxIncrement = [0,0,1];
print( "The current version number is " + oldVersion + "." );
print( "The maximum allowed increment is " + maxIncrement + ".");
nextVersionTest( oldVersion, maxIncrement );

/* Test an invalid version number update */
print( "Testing error condition...\n" );
oldVersion = "1.0";
maxIncrement = [0,2];
print( "The current version number is " + oldVersion + "." );
print( "The maximum allowed increment is " + maxIncrement + ".");
nextVersionTest( oldVersion, maxIncrement );