// Copyright 2024 Matthew Rich . All rights reserved. package source import ( "errors" "fmt" _ "net/url" "strings" _ "path/filepath" "decl/internal/types" ) var ( ErrUnknownSourceType = errors.New("Unknown source type") SourceTypes *types.Types[DocSource] = types.New[DocSource]() ) type TypeName string //`json:"type"` func (n *TypeName) UnmarshalJSON(b []byte) error { SourceTypeName := strings.Trim(string(b), "\"") if SourceTypes.Has(SourceTypeName) { *n = TypeName(SourceTypeName) return nil } return fmt.Errorf("%w: %s", ErrUnknownSourceType, SourceTypeName) }