diff --git a/Extensions/XAiServiceExtensions.cs b/Extensions/XAiServiceExtensions.cs new file mode 100644 index 0000000..0d45d1e --- /dev/null +++ b/Extensions/XAiServiceExtensions.cs @@ -0,0 +1,44 @@ +using xCommons.Extensions; +using xExceptions.Constants; +using xIdentityModels.Models; + +namespace xAiService.Extensions +{ + public static class XAiServiceExtensions + { + /// + /// Validate User Info ... + /// + /// + /// + public static bool IsValid(this XUserClaimsInfoDto userInfo) + { + // + var result = + !userInfo.IsNullOrDefault() && + !userInfo.UserId.IsNullOrEmpty() && + !userInfo.AccessToken.IsNullOrEmpty(); + + // + return result; + } + + /// + /// Validate User Info ... + /// + /// + /// + public static void Validate( + this XUserClaimsInfoDto userInfo, + XException invalidException = XException.InvalidArgs + ) + { + // + var isValid = userInfo.IsValid(); + if (!isValid) + { + invalidException.Throw(); + } + } + } +} \ No newline at end of file