Files
2025-05-01 07:20:41 +09:00

39 lines
1.7 KiB
C#

using ServerBase;
using MetaAssets;
namespace ServerCommon;
public static class ShopValidator
{
[MetaValidator]
public static void Validate(ShopMetaData shop, ValidatorErrorCollection errors)
{
// 1. resetTime
if(shop.ResetTime <= 0)
errors.add($"Invalid shop : reset time is invalid [{shop.ResetTime}]");
// 2. product group
if(false == CommonValidator.isExistProductGroupId(shop.ShopProduct_Group_Id))
errors.add($"Invalid shop : product group id is invalid [{shop.ShopProduct_Group_Id}]");
}
[MetaValidator]
public static void Validate(ShopProductMetaData shopProduct, ValidatorErrorCollection errors)
{
// 1. Buy 정보 체크
if(shopProduct.Buy_Price_Type == ShopBuyType.Currency && false == CommonValidator.isExistCurrencyId(shopProduct.Buy_Id))
errors.add($"Invalid shop product : buy currency type is invalid - [{shopProduct.Buy_Id}]");
if(shopProduct.Buy_Price_Type == ShopBuyType.Item && false == CommonValidator.isExistItemId(shopProduct.Buy_Id))
errors.add($"Invalid shop product : buy item id is not exist - [{shopProduct.Buy_Id}]");
// 2. Product 정보 체크
if(shopProduct.ProductData.Currency != null && false == CommonValidator.isExistCurrencyId(shopProduct.ProductData.Currency.Id))
errors.add($"Invalid shop product : product currency type is invalid - [{shopProduct.ProductData.Currency.Id}]");
if(shopProduct.ProductData.Item != null && false == CommonValidator.isExistItemId(shopProduct.ProductData.Item.Id))
errors.add($"Invalid shop product : product item id is not exist - [{shopProduct.ProductData.Item.Id}]");
}
}