function typecast(schema, callback) {
      var params = {};
      // normalize constraints
      switch (schema.type) {
          case 'integer':
          case 'number':
              if (typeof schema.minimum !== 'undefined') {
                  params.minimum = schema.minimum;
              }
              if (typeof schema.maximum !== 'undefined') {
                  params.maximum = schema.maximum;
              }
              if (schema.enum) {
                  var min = Math.max(params.minimum || 0, 0);
                  var max = Math.min(params.maximum || Infinity, Infinity);
                  min = handleExclusiveMinimum(schema, min);
                  max = handleExclusiveMaximum(schema, max);
                  // discard out-of-bounds enumerations
                  schema.enum = schema.enum.filter(function (x) {
                      if (x >= min && x <= max) {
                          return true;
                      }
                      return false;
                  });
              }
              break;
          case 'string':
              if (typeof schema.minLength !== 'undefined') {
                  params.minLength = schema.minLength;
              }
              if (typeof schema.maxLength !== 'undefined') {
                  params.maxLength = schema.maxLength;
              }
              var _maxLength = optionAPI('maxLength');
              var _minLength = optionAPI('minLength');
              // Don't allow user to set max length above our maximum
              if (_maxLength && params.maxLength > _maxLength) {
                  params.maxLength = _maxLength;
              }
              // Don't allow user to set min length above our maximum
              if (_minLength && params.minLength < _minLength) {
                  params.minLength = _minLength;
              }
              break;
      }
      // execute generator
      var value = callback(params);

      /**
       * CHANGE: This Makes sure that we're not typecasting null to "null"
       */
      if (_.get(schema, 'nullable') && value === null) {
        return value;
      }

      // normalize output value
      switch (schema.type) {
          case 'number':
              value = parseFloat(value);
              break;
          case 'integer':
              value = parseInt(value, 10);
              break;
          case 'boolean':
              value = !!value;
              break;
          case 'string':
              value = String(value);
              var min = Math.max(params.minLength || 0, 0);
              var max = Math.min(params.maxLength || Infinity, Infinity);
              while (value.length < min) {
                  /**
                   * CHANGE: This Makes sure that we're not adding extra spaces in generated value,
                   * As such behaviour generates invalid data when pattern is mentioned.
                   *
                   * To avoid infinite loop, make sure we keep adding spaces in cases where value is empty string
                   */
                  value += ((schema.pattern && value.length !== 0) ? '' : ' ') + value;
              }
              if (value.length > max) {
                  value = value.substr(0, max);
              }
              break;
      }
      return value;
  }
Returns typecasted value.
External generators (faker, chance, casual) may return data in non-expected formats, such as string, when you might expect an
integer. This function is used to force the typecast. This is the base formatter for all result values.

@param schema
@param callback
@returns {any}