lib/forms/index.js
function processInputValue() {
    var value = params.value;
    var index = params.index || 0;
    var fieldType = field.type;

    //Checking for a value.
    if (typeof(value) === "undefined" || value === null) {
      return "No value entered.";
    }

    /**
     * File-base fields (photo, signature and file) need to stream the file to the mongo server.
     */
    if (fieldType === "photo" || fieldType === "signature" || fieldType === "file") {
      //The stream must be a paused stream.
      var fileURI = value.fileStream;

      delete value.fileStream;

      //It must be possible to stream the object to the database.
      var isString=(typeof(fileURI) === "string");
      if (!isString) {
        return "Expected a string URI object when streaming a file-based field ";
      }

      if (!(value.fileName && value.fileSize && value.fileType)) {
        return "Invalid file parameters. Params: " + JSON.stringify(value);
      }

      //Generating a random file hash name.
      var hashName = "filePlaceHolder" + Date.now() + Math.floor(Math.random() * 10000000000000);
      var fileUpdateTime = Date.now;

      self.filesToUpload[hashName] = {
        fieldId: field._id,
        fileStream: fileURI
      };

      value.hashName = hashName;
      value.fileUpdateTime = fileUpdateTime;
    }

    self.fieldValues[field._id] = self.fieldValues[field._id] || [];
    self.fieldValues[field._id][index] = value;
    return undefined;
  }
function processInputValue() {
    var value = params.value;
    var index = params.index || 0;
    var fieldType = field.type;

    //Checking for a value.
    if (typeof(value) === "undefined" || value === null) {
      return "No value entered.";
    }

    /**
     * File-base fields (photo, signature and file) need to stream the file to the mongo server.
     */
    if (fieldType === "photo" || fieldType === "signature" || fieldType === "file") {
      //The stream must be a paused stream.
      var fileURI = value.fileStream;

      delete value.fileStream;

      //It must be possible to stream the object to the database.
      var isString=(typeof(fileURI) === "string");
      if (!isString) {
        return "Expected a string URI object when streaming a file-based field ";
      }

      if (!(value.fileName && value.fileSize && value.fileType)) {
        return "Invalid file parameters. Params: " + JSON.stringify(value);
      }

      //Generating a random file hash name.
      var hashName = "filePlaceHolder" + Date.now() + Math.floor(Math.random() * 10000000000000);
      var fileUpdateTime = Date.now;

      self.filesToUpload[hashName] = {
        fieldId: field._id,
        fileStream: fileURI
      };

      value.hashName = hashName;
      value.fileUpdateTime = fileUpdateTime;
    }

    self.fieldValues[field._id] = self.fieldValues[field._id] || [];
    self.fieldValues[field._id][index] = value;
    return undefined;
  }
function processInputValue ( ) { var value = params . value ; var index = params . index || 0 ; var fieldType = field . type ; //Checking for a value. if ( typeof ( value ) === "undefined" || value === null ) { return "No value entered." ; } /**
     * File-base fields (photo, signature and file) need to stream the file to the mongo server.
     */ if ( fieldType === "photo" || fieldType === "signature" || fieldType === "file" ) { //The stream must be a paused stream. var fileURI = value . fileStream ; delete value . fileStream ; //It must be possible to stream the object to the database. var isString = ( typeof ( fileURI ) === "string" ) ; if ( ! isString ) { return "Expected a string URI object when streaming a file-based field " ; } if ( ! ( value . fileName && value . fileSize && value . fileType ) ) { return "Invalid file parameters. Params: " + JSON . stringify ( value ) ; } //Generating a random file hash name. var hashName = "filePlaceHolder" + Date . now ( ) + Math . floor ( Math . random ( ) * 10000000000000 ) ; var fileUpdateTime = Date . now ; self . filesToUpload [ hashName ] = { fieldId : field . _id , fileStream : fileURI } ; value . hashName = hashName ; value . fileUpdateTime = fileUpdateTime ; } self . fieldValues [ field . _id ] = self . fieldValues [ field . _id ] || [ ] ; self . fieldValues [ field . _id ] [ index ] = value ; return undefined ; }
Adding a value to an index.
Most inputs are validated by the rules engine, but file inputs need to be a file location on the local app.
It is advisible to download the file to local storage first.
@returns {error/undefined}
Adding a value to an index . Most inputs are validated by the rules engine but file inputs need to be a file location on the local app . It is advisible to download the file to local storage first .