Detect the ideal type for the data, either using the explicit type
    definition or the format (for date, date-time, not supported by JSON).
192630
def get_type(bind):
    
    types = bind.types + [bind.schema.get('format')]
    for type_name in ('date-time', 'date', 'decimal', 'integer', 'boolean',
                      'number', 'string'):
        if type_name in types:
            return type_name
    return 'string'
200692
def datatype(self, value):
        
        self._datatype = self.validate_datatype(value)
        self._cutout_ready = True
31834
function (type, data) {
  if (type === 'size') {
    return `File size should be less than ${bytes(data.size)}`
  }

  if (type === 'type') {
    const verb = data.types.length === 1 ? 'is' : 'are'
    return `Invalid file type ${data.subtype} or ${data.type}. Only ${data.types.join(', ')} ${verb} allowed`
  }

  if (type === 'extname') {
    const verb = data.extnames.length === 1 ? 'is' : 'are'
    return `Invalid file extension ${data.extname}. Only ${data.extnames.join(', ')} ${verb} allowed`
  }
}
810535
private Object correctDataType(Object value, String dataType) {
		if(value == null ){return null;}
		return value;
	}
84625
def date(self, value=None):
        
        if not (value is None):
            if (self.metadatatype == "native"):
                self.metadata['date'] = value
            else:
                self._date = value
        if (self.metadatatype == "native"):
            if 'date' in self.metadata:
                return self.metadata['date']
            else:
                return None
        else:
            return self._date
1226440
def typeof_rave_data(value):
    """"""

    # Test if value is a date
    for format in ['%d %b %Y', '%b %Y', '%Y', '%d %m %Y', '%m %Y', '%d/%b/%Y', '%b/%Y', '%d/%m/%Y', '%m/%Y']:
        try:
            datetime.datetime.strptime(value, format)
            if len(value) == 4 and (int(value) < 1900 or int(value) > 2030):
                break
            return ('date', format)
        except ValueError:
            pass
        except TypeError:
            pass

    # Test if value is a time
    for format in ['%H:%M:%S', '%H:%M', '%I:%M:%S', '%I:%M', '%I:%M:%S %p', '%I:%M %p']:
        try:
            datetime.datetime.strptime(value, format)
            return ('time', format)
        except ValueError:
            pass
        except TypeError:
            pass

    # Test if value is a integer
    try:
        if ((isinstance(value, str) and isinstance(int(value), int)) \
                    or isinstance(value, int)):
            return ('int', None)
    except ValueError:
        pass
    except TypeError:
        pass

    # Test if value is a float
    try:
        float(value)
        return ('float', None)
    except ValueError:
        pass
    except TypeError:
        pass

    # If no match on anything else, assume its a string
    return ('string', None)
446725
def _is_type_compatible(a, b):
    """"""
    is_ts_compat = lambda x: isinstance(x, (Timestamp, DateOffset))
    is_td_compat = lambda x: isinstance(x, (Timedelta, DateOffset))
    return ((is_number(a) and is_number(b)) or
            (is_ts_compat(a) and is_ts_compat(b)) or
            (is_td_compat(a) and is_td_compat(b)) or
            com._any_none(a, b))
610822
def date(value):
    
    if isinstance(value, str):
        value = to_date(value)
    return literal(value, type=dt.date)
164655
def _coerce_type(self, field_type, value):
        
        if value is None:
            return None
        if field_type == 'string':
            return str(value)
        elif field_type == 'text':
            return str(value)
        elif field_type == 'int':
            try:
                v = int(value)
                return str(v)
            except:
                return None
        elif field_type == 'float':
            try:
                v = float(value)
                return str(v)
            except:
                return None
        elif field_type == 'date':
            try:
                v = datetime.datetime(
                    value['year'],
                    value['month'],
                    value['day'],
                    value['hour'],
                    value['minute'],
                    value['second'],
                )
                v = v.strftime('%Y-%m-%dT%H:%M:%S.0Z')
                return v
            except:
                return None
        return str(value)
852080
function getType(val) {
		switch (typeof val) {
			case 'object':
				return !val ? NUL : (isArray(val) ? ARY : (isMarkup(val) ? RAW : ((val instanceof Date) ? VAL : OBJ)));
			case 'function':
				return FUN;
			case 'undefined':
				return NUL;
			default:
				return VAL;
		}
	}
901985
def check_type(value, type_def):
        
        if type_def == 'integer':
            try:
                # We accept string with integer ex: '123'
                int(value)
                return True
            except ValueError:
                return isinstance(value, six.integer_types) and not isinstance(value, bool)
        elif type_def == 'number':
            return isinstance(value, (six.integer_types, float)) and not isinstance(value, bool)
        elif type_def == 'string':
            return isinstance(value, (six.text_type, six.string_types, datetime.datetime))
        elif type_def == 'boolean':
            return (isinstance(value, bool) or
                    (isinstance(value, (six.text_type, six.string_types,)) and
                     value.lower() in ['true', 'false'])
                    )
        else:
            return False
175954
def json_schema_validation_format(value, schema_validation_type):
    
    DEFAULT_FORMAT_VALIDATORS['date-time'] = validate_format_iso8601
    DEFAULT_FORMAT_VALIDATORS['text'] = validate_format_text
    validictory.validate(value, schema_validation_type, format_validators=DEFAULT_FORMAT_VALIDATORS)
1203032
def isdatetime(value):
    
    if isinstance(value, np.ndarray):
        return (value.dtype.kind == "M" or
                (value.dtype.kind == "O" and len(value) and
                 isinstance(value[0], datetime_types)))
    else:
        return isinstance(value, datetime_types)
1140461
def _python_type(self, key, value):
        """"""
        try:
            field_type = self._sp_cols[key]['type']
            if field_type in ['Number', 'Currency']:
                return float(value)
            elif field_type == 'DateTime':


                # Need to remove the '123;#' from created dates, but we will do it for all dates
                # self.date_format = re.compile('\d+-\d+-\d+ \d+:\d+:\d+')
                value = self.date_format.search(value).group(0)
                
                # NOTE: I used to round this just date (7/28/2018)
                return datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
            elif field_type == 'Boolean':
                if value == '1':
                    return 'Yes'
                elif value == '0':
                    return 'No'
                else:
                    return ''
            elif field_type in ('User', 'UserMulti'):
                # Sometimes the User no longer exists or
                # has a diffrent ID number so we just remove the "123;#"
                # from the beginning of their name
                if value in self.users['sp']:
                    return self.users['sp'][value]
                elif '#' in value:
                    return value.split('#')[1]
                else:
                    return value
            else:
                return value
        except AttributeError:
            return value
1187269
function(typeCode) {
        switch (typeCode) {
          case this.types.undefined:
            return this.Undefined;
          case this.types.string:
            return this.String;
          case this.types.integer:
            return this.Integer;
          case this.types.double:
            return this.Double;
          case this.types.boolean:
            return this.Boolean;
          case this.types["null"]:
            return this.Null;
          case this.types.datetime:
            return this.DateTime;
          case this.types.array:
            return this.Array;
          case this.types.object:
            return this.Object;
          case this.types["function"]:
            return this.Function;
          default:
            throw new Error("Unknown typeCode \"" + typeCode + "\".");
        }
      }
1015545
function convertDateType (data) {
  if (!(data.type === 'string' && data.pattern)) {
    return data
  }
  const pattern = data.pattern
  delete data.pattern
  switch (pattern) {
    case constants.dateOnlyPattern:
      data['type'] = 'date-only'
      break
    case constants.timeOnlyPattern:
      data['type'] = 'time-only'
      break
    case constants.dateTimeOnlyPattern:
      data['type'] = 'datetime-only'
      break
    case constants.RFC3339DatetimePattern:
      data['type'] = 'datetime'
      data['format'] = constants.RFC3339
      break
    case constants.RFC2616DatetimePattern:
      data['type'] = 'datetime'
      data['format'] = constants.RFC2616
      break
    default:
      data['pattern'] = pattern
  }
  return data
}
660783
def data_type(self, data_type):
        
        allowed_values = ["string", "number", "date", "color"]
        if data_type is not None and data_type not in allowed_values:
            raise ValueError(
                "Invalid value for `data_type` ({0}), must be one of {1}"
                .format(data_type, allowed_values)
            )

        self._data_type = data_type