Code/SboxSuperuser/Core/Identity/SteamIdentity.cs

A small static helper that validates a Steam ID string. It ensures the input is nonempty, does not start with '0', contains only decimal digits, and can be parsed as an unsigned 64-bit integer, otherwise it throws an ArgumentException.

namespace SboxSuperuser.Core.Identity;

internal static class SteamIdentity
{
	internal static string Validate( string value, string parameter )
	{
		if ( string.IsNullOrEmpty( value ) || value[ 0 ] == '0'
			|| value.Any( character => character is < '0' or > '9' )
			|| !ulong.TryParse( value, out _ ) )
		{
			throw new ArgumentException( "Use a nonzero canonical decimal Steam ID.", parameter );
		}

		return value;
	}
}