Skip to content

Fix null handling for newly nullable columns in Player entity #209

Open
@coderabbitai

Description

@coderabbitai

Background

In PR #208 (feature/identifiers), several columns in the Player entity were changed from non-nullable to nullable:

  • FirstName
  • LastName
  • Position
  • AbbrPosition
  • DateOfBirth

Issues Identified

The code review identified potential null handling concerns:

  1. The validator () enforces non-null/empty values for FirstName, LastName, and AbbrPosition, but there's no corresponding check for DateOfBirth or Position.

  2. In the mapping profile (), the DateOfBirth property is formatted directly using string interpolation ($"{source.DateOfBirth:MMMM d, yyyy}"), which can throw an exception if DateOfBirth is null.

  3. While test files currently provide values for these columns, null scenarios may occur in production.

Recommended Actions

  • DateOfBirth: Update the mapping to safely handle null values (e.g., use a conditional to supply a default string or check for HasValue) or enforce non-null validation if a value is required.
  • Position: Confirm that the intended behavior for nullable Position is correctly managed in both validation and mapping scenarios.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .NET codeenhancementNew feature or requestgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions