code: function castDate(format, value) {
    if (!isDate(value)) {
      if (!isString(value)) {
        return ERROR
      }
      try {
        if (format === 'default') {
          value = moment(timeParse(_DEFAULT_PATTERN)(value))
        } else if (format === 'any') {
          value = moment(value)
        } else {
          if (format.startsWith('fmt:')) {
            console.warn(
              `Format "fmt:<PATTERN>" is deprecated.
               Please use "<PATTERN>" without "fmt:" prefix.`)
            format = format.replace('fmt:', '')
          }
          value = moment(timeParse(format)(value))
        }
        if (!value.isValid()) {
          return ERROR
        }
        value = value.toDate()
      } catch (error) {
        return ERROR
      }
    }
    return value
  }
docs: Module API