Reuse document indexes in D&D normalization
This commit is contained in:
@@ -77,11 +77,11 @@ func (ref UnitRef) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(ref.String())
|
||||
}
|
||||
|
||||
func ResolveUnitID(doc *source.SourceDocument, field string, ref UnitRef) (int, error) {
|
||||
func ResolveUnitID(index source.DocumentIndex, field string, ref UnitRef) (int, error) {
|
||||
if ref.value <= 0 {
|
||||
return 0, fmt.Errorf("%s must be positive", field)
|
||||
}
|
||||
if _, ok := source.UnitIndex(doc, ref.value); !ok {
|
||||
if _, ok := index.Position(ref.value); !ok {
|
||||
return 0, fmt.Errorf("%s %d was not found", field, ref.value)
|
||||
}
|
||||
return ref.value, nil
|
||||
|
||||
Reference in New Issue
Block a user