Skip to content

Commit

Permalink
Add additional option validation
Browse files Browse the repository at this point in the history
  • Loading branch information
gunpuz committed Aug 21, 2024
1 parent 05d3172 commit 7f7d74e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Tilde.Translation/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ public Translator(string apiKey, TranslatorOptions? options = null)
{
options ??= new TranslatorOptions();

if (string.IsNullOrWhiteSpace(options.AppInfo?.AppVersion))
if (options.AppInfo != null)
{
throw new ArgumentNullException($"{nameof(options)}.{nameof(options.AppInfo)}.{nameof(options.AppInfo.AppVersion)}");
}
if (string.IsNullOrWhiteSpace(options.AppInfo.AppVersion))
{
throw new ArgumentNullException($"{nameof(options)}.{nameof(options.AppInfo)}.{nameof(options.AppInfo.AppVersion)}");
}

if (string.IsNullOrWhiteSpace(options.AppInfo?.AppName))
{
throw new ArgumentNullException($"{nameof(options)}.{nameof(options.AppInfo)}.{nameof(options.AppInfo.AppName)}");
if (string.IsNullOrWhiteSpace(options.AppInfo.AppName))
{
throw new ArgumentNullException($"{nameof(options)}.{nameof(options.AppInfo)}.{nameof(options.AppInfo.AppName)}");
}
}

if (apiKey == null)
Expand Down

0 comments on commit 7f7d74e

Please sign in to comment.