public void Validate()
{
if (string.IsNullOrWhiteSpace(ConnectionString))
{
throw new ValidationArgException("Connection string is required for adding a range map shard.");
}
if (string.IsNullOrWhiteSpace(MapName))
{
throw new ValidationArgException("Map name is required for adding a range map shard.");
}
if (ShardKeyRange == null)
{
throw new ValidationArgException("Shard key range was not provided, is invalid, or is in an incorrect format.");
}
if (ShardKeyRange.KeyType == null)
{
throw new ValidationArgException("Shard key range type was not provided, is invalid, or could not be parsed.");
}
if (ShardKeyRange.LowValue == null)
{
throw new ValidationArgException("Shard key range low value was not provided, is invalid, or could not be parsed.");
}
if (ShardKeyRange.HighValue == null)
{
throw new ValidationArgException("Shard key range high value was not provided, is invalid, or could not be parsed.");
}
if (string.IsNullOrWhiteSpace(ShardServerName))
{
throw new ValidationArgException("Shard server name is required for adding a range map shard.");
}
if (string.IsNullOrWhiteSpace(ShardDatabaseName))
{
throw new ValidationArgException("Shard database name is required for adding a range map shard.");
}
var highValueComparable = (IComparable)ShardKeyRange.HighValue;
var isHighValueLargerThanLowValue = (highValueComparable.CompareTo(ShardKeyRange.LowValue) > 0);
if (!isHighValueLargerThanLowValue)
{
throw new ValidationArgException($"Shard key range low value {ShardKeyRange.LowValue} is greater than high value {ShardKeyRange.HighValue}.");
}
}
}