feat: валидация значений полей с вариантами (4099)#4100
Open
claude[bot] wants to merge 2 commits intomasterfrom
Open
feat: валидация значений полей с вариантами (4099)#4100claude[bot] wants to merge 2 commits intomasterfrom
claude[bot] wants to merge 2 commits intomasterfrom
Conversation
- Добавлен FieldValueInvalidException для некорректных ID вариантов - Валидация в FieldSaveStrategyBase.NormalizeValueBeforeAssign для Dropdown/MultiSelect полей - CharacterApiController возвращает 400 Bad Request при FieldValueInvalidException - Юнит-тесты: TryToSetInvalidDropdownValue, SetValidDropdownValue, TryToSetInvalidMultiSelectValue - Тест API-контроллера: SetCharacterFields_InvalidVariantId_ReturnsBadRequest Closes #4099 Co-authored-by: Leonid Tsarev <leotsarev@users.noreply.github.com>
leotsarev
reviewed
Mar 29, 2026
src/JoinRpg.Domain/Exceptions.cs
Outdated
| public string FieldName { get; } = fieldName; | ||
| } | ||
|
|
||
| public class FieldValueInvalidException(string fieldName, int variantId) |
Member
There was a problem hiding this comment.
Здесь должно быть типизированный id поля
leotsarev
reviewed
Mar 29, 2026
|
|
||
| namespace JoinRpg.Portal.Test.XGameApi; | ||
|
|
||
| public class CharacterFieldsApiTest |
leotsarev
reviewed
Mar 29, 2026
Member
leotsarev
left a comment
There was a problem hiding this comment.
- Добавить интеграционный тест в XApiCharacterTests
Member
|
@claude fix review comments |
Contributor
Author
|
Claude finished @leotsarev's task in 15m 24s —— View job Исправление замечаний ревью
Что сделано
public class FieldValueInvalidException(ProjectFieldIdentification fieldId, int variantId)
: JoinRpgBaseException($"Поле {fieldId}: значение {variantId} не является допустимым вариантом")
{
public ProjectFieldIdentification FieldId { get; } = fieldId;
public int VariantId { get; } = variantId;
}В Удалён Добавлен интеграционный тест в [Fact]
public async Task SetDropdownField_InvalidVariantId_Returns400()| Branch |
…ный тест - FieldValueInvalidException принимает ProjectFieldIdentification вместо string - Удален дублирующий unit-тест CharacterFieldsApiTest - Добавлен интеграционный тест SetDropdownField_InvalidVariantId_Returns400 Co-authored-by: Leonid Tsarev <leotsarev@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что сделано
FieldValueInvalidException— выбрасывается при попытке установить ID варианта, которого нет у поляFieldSaveStrategyBase.NormalizeValueBeforeAssign— срабатывает для всех полей с вариантами (Dropdown, MultiSelect, ScheduleRoomField, ScheduleTimeSlotField)CharacterApiController.SetCharacterFieldsтеперь возвращает400 Bad RequestприFieldValueInvalidExceptionТесты
Юнит-тесты в
JoinRpg.Domain.Test/FieldSaveHelperTest.cs:TryToSetInvalidDropdownValue— попытка установить несуществующий ID варианта в Dropdown-полеSetValidDropdownValue— успешная установка корректного ID вариантаTryToSetInvalidMultiSelectValue— попытка установить частично некорректный список ID в MultiSelect-полеТест на уровне API-контроллера в
JoinRpg.Portal.Test/XGameApi/CharacterFieldsApiTest.cs:SetCharacterFields_InvalidVariantId_ReturnsBadRequest— API возвращает 400 при невалидном вариантеSetCharacterFields_Success_ReturnsOk— API возвращает "ok" при корректном запросеCloses #4099
Generated with Claude Code