6 Replies
return on the first if and just keep the other if's (not nested in else if)
can you provide me the modified code ?
not behind a pc atm 😄
You could try pattern matching, but I really suggest you find an entirely different approach for the top and bottom commented out sections.
.ForEach
is a code smell. Also, likely every time you type a letter (ie. the binding is changing), you're reallocating a new list for the filter on the ErrorList.ToList()
line.Also it looks like you're already using some form of validation library, this is basically what it's made for...
fluentvalidation, for example, you'd just define
RuleFor(x => x.PetName).NotEmpty().Length(3,255).NotEqual("Snow")
Yeah, this is Mvvm Toolkit's validation, so you want a different approach if there's nothing really specific to be handled in
INotifyPropertyChanging
.
Something like https://paste.mod.gg/vsemuppbvcqv/0 is significantly better. You might be able to get away with only Data Annotations. Might be a neater way to write the switch expression too.