mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
Blank accountId stays optional; nonblank parse failures return 400. Account lookup uses ExistsActiveAsync with the request token.
25 lines
684 B
C#
25 lines
684 B
C#
using System.Globalization;
|
|
using FluentValidation;
|
|
using FluentValidation.Results;
|
|
|
|
namespace Api.SeaHavenIndustries.DTOs
|
|
{
|
|
internal static class LocationAccountIdMapping
|
|
{
|
|
public static int? ParseOptional(string? raw)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(raw))
|
|
return null;
|
|
|
|
if (!int.TryParse(raw.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out var id))
|
|
{
|
|
throw new ValidationException(new[]
|
|
{
|
|
new ValidationFailure("AccountId", "accountId must be a valid integer.")
|
|
});
|
|
}
|
|
|
|
return id;
|
|
}
|
|
}
|
|
}
|