From 4af7d2f6ff8b38365c97a89c295710f5ed3266f5 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 30 Mar 2026 17:56:42 +0200 Subject: Manage insertion for multireferences fields --- lib/model/content.ml | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/model/content.ml') diff --git a/lib/model/content.ml b/lib/model/content.ml index 2760715..4fe8e92 100644 --- a/lib/model/content.ml +++ b/lib/model/content.ml @@ -28,3 +28,16 @@ let fields : 'a t -> 'a Field.t Seq.t = fun t -> List.to_seq t.sections |> Seq.flat_map (fun section -> List.to_seq section.Section.fields) + +let find_target : 'a t -> string -> 'a option = + fun t name -> + let feature_opt = + Seq.find (fun f -> String.equal (Field.name f) name) (fields t) + in + + let ( let* ) = Option.bind in + let* feature : 'a Field.t = feature_opt in + let (T feature_type) = Field.type_ feature in + match feature_type with + | MonoReference t | MultiReference t -> Some t.Typ.t + | Integer | Text -> None -- cgit v1.2.3