lib/common/forms-rule-engine.js
function validatorDropDown(fieldValue, fieldDefinition, previousFieldValues, cb) {
      if (typeof(fieldValue) !== "string") {
        return cb(new Error("Expected submission to be string but got " + typeof(fieldValue)));
      }

      fieldDefinition.fieldOptions = fieldDefinition.fieldOptions || {};
      fieldDefinition.fieldOptions.definition = fieldDefinition.fieldOptions.definition || {};

      //Check values exists in the field definition
      if (!fieldDefinition.fieldOptions.definition.options) {
        return cb(new Error("No options exist for field " + fieldDefinition.name));
      }

      //Finding the selected option
      var found = _.find(fieldDefinition.fieldOptions.definition.options, function(dropdownOption) {
        //check if fieldValue and the label need to be escaped
        isSafeString(fieldValue) ? null : fieldValue = _.escape(fieldValue);
        isSafeString(dropdownOption.label) ? null : dropdownOption.label = _.escape(dropdownOption.label);
        return dropdownOption.label === fieldValue;
      });

      //Valid option, can return
      if (found) {
        return cb();
      }

      //If the option is empty and the field is required, then the blank option is being submitted
      //The blank option is not valid for a required field.
      if (found === "" && fieldDefinition.required && fieldDefinition.fieldOptions.definition.include_blank_option) {
        return cb(new Error("The Blank Option is not valid. Please select a value."));
      } else {
        //Otherwise, it is an invalid option
        return cb(new Error("Invalid option specified: " + fieldValue));
      }
    }
function validatorDropDown(fieldValue, fieldDefinition, previousFieldValues, cb) {
      if (typeof(fieldValue) !== "string") {
        return cb(new Error("Expected submission to be string but got " + typeof(fieldValue)));
      }

      fieldDefinition.fieldOptions = fieldDefinition.fieldOptions || {};
      fieldDefinition.fieldOptions.definition = fieldDefinition.fieldOptions.definition || {};

      //Check values exists in the field definition
      if (!fieldDefinition.fieldOptions.definition.options) {
        return cb(new Error("No options exist for field " + fieldDefinition.name));
      }

      //Finding the selected option
      var found = _.find(fieldDefinition.fieldOptions.definition.options, function(dropdownOption) {
        //check if fieldValue and the label need to be escaped
        isSafeString(fieldValue) ? null : fieldValue = _.escape(fieldValue);
        isSafeString(dropdownOption.label) ? null : dropdownOption.label = _.escape(dropdownOption.label);
        return dropdownOption.label === fieldValue;
      });

      //Valid option, can return
      if (found) {
        return cb();
      }

      //If the option is empty and the field is required, then the blank option is being submitted
      //The blank option is not valid for a required field.
      if (found === "" && fieldDefinition.required && fieldDefinition.fieldOptions.definition.include_blank_option) {
        return cb(new Error("The Blank Option is not valid. Please select a value."));
      } else {
        //Otherwise, it is an invalid option
        return cb(new Error("Invalid option specified: " + fieldValue));
      }
    }
function validatorDropDown ( fieldValue , fieldDefinition , previousFieldValues , cb ) { if ( typeof ( fieldValue ) !== "string" ) { return cb ( new Error ( "Expected submission to be string but got " + typeof ( fieldValue ) ) ) ; } fieldDefinition . fieldOptions = fieldDefinition . fieldOptions || { } ; fieldDefinition . fieldOptions . definition = fieldDefinition . fieldOptions . definition || { } ; //Check values exists in the field definition if ( ! fieldDefinition . fieldOptions . definition . options ) { return cb ( new Error ( "No options exist for field " + fieldDefinition . name ) ) ; } //Finding the selected option var found = _ . find ( fieldDefinition . fieldOptions . definition . options , function ( dropdownOption ) { //check if fieldValue and the label need to be escaped isSafeString ( fieldValue ) ? null : fieldValue = _ . escape ( fieldValue ) ; isSafeString ( dropdownOption . label ) ? null : dropdownOption . label = _ . escape ( dropdownOption . label ) ; return dropdownOption . label === fieldValue ; } ) ; //Valid option, can return if ( found ) { return cb ( ) ; } //If the option is empty and the field is required, then the blank option is being submitted //The blank option is not valid for a required field. if ( found === "" && fieldDefinition . required && fieldDefinition . fieldOptions . definition . include_blank_option ) { return cb ( new Error ( "The Blank Option is not valid. Please select a value." ) ) ; } else { //Otherwise, it is an invalid option return cb ( new Error ( "Invalid option specified: " + fieldValue ) ) ; } }
validatorDropDown - Validator function for dropdown fields.

@param  {string} fieldValue        The value to validate
@param  {object} fieldDefinition   Full JSON definition of the field
@param  {array} previousFieldValues Any values previously stored with the fields
@param  {function} cb               Callback function
validatorDropDown - Validator function for dropdown fields .