storipress/karbon

View on GitHub
packages/custom-field/model/path.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { FieldType } from './field'
import { isValidType } from './field'

export interface ParsedPath {
  key: string
  type: FieldType
}

export function parsePath(path: string): ParsedPath | null {
  const [key, type] = path.split('::')
  if (!isValidType(type)) {
    return null
  }
  return { key, type }
}