mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-03 02:13:31 +00:00
26 lines
684 B
C#
26 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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|