Skip to content

Commit

Permalink
Check model validity
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Ghanam committed Oct 8, 2024
1 parent 72e15e0 commit 23411a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Altinn.Profile/Controllers/ContactDetailsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public ContactDetailsController(ILogger<ContactDetailsController> logger, IConta
[ProducesResponseType(typeof(ContactDetailsLookupResult), StatusCodes.Status200OK)]
public async Task<ActionResult<ContactDetailsLookupResult>> PostLookup([FromBody] UserContactPointLookup lookupCriteria)
{
if (ModelState.IsValid)
{
return BadRequest(ModelState);
}

if (lookupCriteria?.NationalIdentityNumbers == null || lookupCriteria.NationalIdentityNumbers.Count == 0)
{
return BadRequest("National identity numbers cannot be null or empty.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public ContactDetailsInternalController(ILogger<ContactDetailsInternalController
[ProducesResponseType(typeof(ContactDetailsLookupResult), StatusCodes.Status200OK)]
public async Task<ActionResult<ContactDetailsLookupResult>> PostLookup([FromBody] UserContactPointLookup request)
{
if (ModelState.IsValid)
{
return BadRequest(ModelState);
}

if (request?.NationalIdentityNumbers == null || request.NationalIdentityNumbers.Count == 0)
{
return BadRequest("National identity numbers cannot be null or empty.");
Expand Down

0 comments on commit 23411a1

Please sign in to comment.