Priority: P2 - Important
Tier: 3 - Advanced Features
Effort: Medium (6-8 hours)
Already In Codebase
- Requiredness is already calculated and passed into runtime Get methods:
- Field override + global default requiredness:
src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/PropertyMappingSpecBuilder.cs
- Runtime behavior on missing keys:
Requiredness.Required and Requiredness.InferFromNullability currently throw InvalidOperationException.
Requiredness.Optional returns a DynamoDB NULL value.
src/LayeredCraft.DynamoMapper.Runtime/AttributeValueExtensions/UtilAttributeValueExtensions.cs
- There are tests that exercise requiredness override scenarios:
test/LayeredCraft.DynamoMapper.Generators.Tests/DynamoFieldVerifyTests.cs
Goal
Improve required field validation behavior in FromItem:
- Ensure requiredness rules are consistently enforced.
- Throw a purpose-built
DynamoMappingException (already exists) with useful context (mapper/type/field/member).
Implementation notes
- Prefer updating runtime Get helpers to throw
DynamoMappingException instead of InvalidOperationException.
- Include:
- mapper name
- target type
- field name
- member name
- details about what was missing
- Ensure behavior is consistent for:
- required non-nullable members
[DynamoField(Required = true/false)] overrides
DefaultRequiredness mapper option
Tests
- Add verify/behavior tests for missing required fields that validate the thrown exception type/message.
Acceptance criteria
- Missing required fields throw
DynamoMappingException with actionable details.
- Optional fields remain optional and do not throw.
- Tests cover both required and optional cases.
Priority: P2 - Important
Tier: 3 - Advanced Features
Effort: Medium (6-8 hours)
Already In Codebase
src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/PropertyMappingSpecBuilder.csRequiredness.RequiredandRequiredness.InferFromNullabilitycurrently throwInvalidOperationException.Requiredness.Optionalreturns a DynamoDB NULL value.src/LayeredCraft.DynamoMapper.Runtime/AttributeValueExtensions/UtilAttributeValueExtensions.cstest/LayeredCraft.DynamoMapper.Generators.Tests/DynamoFieldVerifyTests.csGoal
Improve required field validation behavior in
FromItem:DynamoMappingException(already exists) with useful context (mapper/type/field/member).Implementation notes
DynamoMappingExceptioninstead ofInvalidOperationException.[DynamoField(Required = true/false)]overridesDefaultRequirednessmapper optionTests
Acceptance criteria
DynamoMappingExceptionwith actionable details.