Skip to content

Commit

Permalink
[C#] Add validation to DTOs and improve use of records.
Browse files Browse the repository at this point in the history
The aim of these changes are to avoid multiple representations in DTOs
and to support read-only views over data.

The new validation includes:

- Checking null values "idiomatic null values" rather than the reserved
null value, to prevent against multiple kinds of null in DTOs.

- Checking primitive field values are at least `minValue` and at most
`maxValue`. Note that this validation is not applied to fixed-size
arrays as the specification says, "Data range attributes minValue and
maxValue do not apply", under the "Fixed-length data" section.

Records are now immutable. Record expressions, i.e., using `with`, are
supported and will apply validation, as we have customised the `init`
property accessor.

I have not included support for encoding null composite values from
DTOs; however, in theory, this could be added later.
  • Loading branch information
ZachBray committed Oct 18, 2023
1 parent 6f2a5d6 commit e2706cd
Show file tree
Hide file tree
Showing 2 changed files with 278 additions and 76 deletions.

0 comments on commit e2706cd

Please sign in to comment.