frankcollins3 / ASPokedex

Pokedex with ASP backend / razor pages, and VanillaJS front end
1 stars 0 forks source link

model and data Annotation causing build warning and preventing run [8:12am] #24

Closed frankcollins3 closed 11 months ago

frankcollins3 commented 11 months ago

attempting to do: run the app to check swagger and API endpoints.

error: warning CS8618: Non-nullable property 'pokename' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

here's the model with the error: Screen Shot 2023-09-26 at 8 11 46 AM

proposed approach: minimum viability: remove the data Annotation as it says above. "Consider declaring the property as nullable"

possible improvements:

frankcollins3 commented 11 months ago

initialize to a value: [Required] public string pokename { get; set; } = string.Empty;

allow null this way (I thought removing the data attribute would permit null but the question mark is needed. public string? type { get; set; }

[8:18am]