public override void Validate(string propertyName = null) { base.Validate(propertyName); string currentProperty = nameof(SearchParams); if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty) { SearchParams.Validate(); if (SearchParams.SearchType == SearchType.Channel && !string.IsNullOrWhiteSpace(SearchParams.Channel)) { if (!_twitchService.ChannelNameIsValid(SearchParams.Channel)) { SearchParams.AddError(nameof(SearchParams.Channel), "Invalid channel name!"); } else if (!_twitchService.ChannelExists(SearchParams.Channel)) { SearchParams.AddError(nameof(SearchParams.Channel), "The specified channel does not exist on Twitch!"); } } if (SearchParams.HasErrors) { AddError(currentProperty, "Invalid Search Parameters!"); } } }
public override void Validate(string propertyName = null) { base.Validate(propertyName); string currentProperty = nameof(SearchParams); if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty) { SearchParams.Validate(); if (SearchParams.SearchType == SearchType.Channel && !string.IsNullOrWhiteSpace(SearchParams.Channel) && !_twitchService.ChannelExists(SearchParams.Channel)) { SearchParams.AddError(nameof(SearchParams.Channel), "지정한 채널이 트위치에 없습니다!"); } if (SearchParams.HasErrors) { AddError(currentProperty, "잘못된 검색 매개 변수 입니다!"); } } }