Skip to content

Commit 894bcd8

Browse files
committed
Fix some bugs
1 parent eb935a5 commit 894bcd8

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

Common/Geo/Alpha2CountryCodeAttribute.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@ public sealed class Alpha2CountryCodeAttribute : ValidationAttribute
88
/// <inheritdoc/>
99
protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
1010
{
11-
if (value is null)
12-
return new ValidationResult("Value is null");
13-
1411
if (value is not string asString)
1512
return new ValidationResult("Input type must be string");
1613

17-
if (asString.Length != 2)
18-
return new ValidationResult("Input string must be exactly 2 characters long");
19-
20-
if (asString[0] is not > 'A' and < 'Z' || asString[1] is not > 'A' and < 'Z')
21-
return new ValidationResult("Characters must be uppercase");
14+
if (asString is not [>= 'A' and <= 'Z', >= 'A' and <= 'Z'])
15+
return new ValidationResult("Input string must be exactly 2 uppercase characters");
2216

2317
if (!Alpha2CountryCode.TryParse(asString, out var countryCode))
2418
return new ValidationResult($"Failed to create {nameof(Alpha2CountryCode)}");

LiveControlGateway/LifetimeManager/HubLifetimeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public async Task RemoveDeviceConnection(IHubController hubController)
191191
/// <exception cref="ArgumentNullException"></exception>
192192
public async Task<OneOf.OneOf<HubLifetime, NotFound, Busy>> AddLiveControlConnection(LiveControlController liveControlController)
193193
{
194-
if (!liveControlController.HubId.HasValue) throw new ArgumentException(nameof(liveControlController), "LiveControlController does not have a hubId");
194+
if (!liveControlController.HubId.HasValue) throw new ArgumentException("LiveControlController does not have a hubId", nameof(liveControlController));
195195

196196
using (await _lifetimesLock.LockAsyncScoped())
197197
{

0 commit comments

Comments
 (0)