1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

combined tax updates with other operations

This commit is contained in:
Chad Scharf
2020-06-17 19:49:27 -04:00
parent f7e5f1f15e
commit b7a500eb63
10 changed files with 66 additions and 14 deletions

View File

@ -13,11 +13,17 @@ namespace Bit.Core.Models.Api
[Range(0, 99)]
public short? AdditionalStorageGb { get; set; }
public IFormFile License { get; set; }
public string Country { get; set; }
public string PostalCode { get; set; }
public bool Validate(GlobalSettings globalSettings)
{
return (License == null && !globalSettings.SelfHosted) ||
(License != null && globalSettings.SelfHosted);
if (!(License == null && !globalSettings.SelfHosted) ||
(License != null && globalSettings.SelfHosted))
{
return false;
}
return globalSettings.SelfHosted || !string.IsNullOrWhiteSpace(Country);
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
@ -27,6 +33,11 @@ namespace Bit.Core.Models.Api
{
yield return new ValidationResult("Payment token or license is required.");
}
if (Country == "US" && string.IsNullOrWhiteSpace(PostalCode))
{
yield return new ValidationResult("Zip / postal code is required.",
new string[] { nameof(PostalCode) });
}
}
}
}

View File

@ -3,7 +3,7 @@ using Bit.Core.Enums;
namespace Bit.Core.Models.Api
{
public class PaymentRequestModel
public class PaymentRequestModel : OrganizationTaxInfoUpdateRequestModel
{
[Required]
public PaymentMethodType? PaymentMethodType { get; set; }