diff options
Diffstat (limited to 'lib/configuration')
| -rw-r--r-- | lib/configuration/read_conf.ml | 11 | ||||
| -rw-r--r-- | lib/configuration/tests/errors.t | 35 |
2 files changed, 45 insertions, 1 deletions
diff --git a/lib/configuration/read_conf.ml b/lib/configuration/read_conf.ml index 14ee0b7..67703da 100644 --- a/lib/configuration/read_conf.ml +++ b/lib/configuration/read_conf.ml @@ -92,7 +92,16 @@ module Make (S : Decoders.Decode.S) = struct S.succeed Model.Field.{ rule; message } let field (env : env) : Model.field S.decoder = - let* name = S.field "name" identifier + let* name = + S.field "name" + (S.and_then + (fun name -> + if Model.Identifier.equal name Model.Identifier.id then + S.fail + "the name \"id\" is reserved: it is the primary key of every \ + row" + else S.succeed name) + identifier) and* label = S.field "label" textI18n and* type' = S.field "type" (field_type env) and* required = S.field_opt_or ~default:false "required" S.bool diff --git a/lib/configuration/tests/errors.t b/lib/configuration/tests/errors.t index b23f237..c4552d3 100644 --- a/lib/configuration/tests/errors.t +++ b/lib/configuration/tests/errors.t @@ -334,3 +334,38 @@ A list cannot reference a list declared after it: "content" decoder: References in a list can only target a list declared before it, but got { "content": "second_list" } + +A field cannot be named "id" (reserved: it is the primary key of every row): + + $ tests --configuration <<EOF + > { + > "content": [ + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "id", + > "label": {}, + > "type": "text" + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + in field "content": + while decoding a list: + element 0: + in field "section": + while decoding a list: + element 0: + in field "field": + while decoding a list: + element 0: + in field "name": + the name "id" is reserved: it is the primary key of every row, but got + "id" |
