diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-03-30 17:56:42 +0200 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-04-01 09:49:08 +0200 |
| commit | 4af7d2f6ff8b38365c97a89c295710f5ed3266f5 (patch) | |
| tree | 8b641d4992eac896223c5169a8b7301205685d85 /lib/model/content.ml | |
| parent | 830e7c5d27d161b91402414e6ecd49f1ed818bfb (diff) | |
Manage insertion for multireferences fields
Diffstat (limited to 'lib/model/content.ml')
| -rw-r--r-- | lib/model/content.ml | 13 |
1 files changed, 13 insertions, 0 deletions
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 |
