generated from admin/template
lul
This commit is contained in:
Binary file not shown.
@@ -73,12 +73,20 @@ app.MapDelete("/pokemons/{id}", (int id) =>
|
|||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
List<string> Validate(PokemonInput input)
|
static List<string> Validate(PokemonInput input)
|
||||||
{
|
{
|
||||||
|
var allowedTypes = new[] { "Fire", "Water", "Grass", "Electric", "Psychic", "Normal", "Flying", "Poison" };
|
||||||
var errors = new List<string>();
|
var errors = new List<string>();
|
||||||
if (string.IsNullOrWhiteSpace(input.Name)) errors.Add("Имя не может быть пустым.");
|
|
||||||
if (string.IsNullOrWhiteSpace(input.Type)) errors.Add("Тип не может быть пустым.");
|
if (string.IsNullOrWhiteSpace(input.Name) || input.Name.Trim().Length < 2)
|
||||||
if (input.Level <= 0) errors.Add("Уровень должен быть больше 0.");
|
errors.Add("Name должен быть не короче 2 символов");
|
||||||
|
|
||||||
|
if (!allowedTypes.Contains(input.Type))
|
||||||
|
errors.Add($"Type '{input.Type}' не поддерживается");
|
||||||
|
|
||||||
|
if (input.Level < 1 || input.Level > 100)
|
||||||
|
errors.Add("Level должен быть в диапазоне 1..100");
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user