uon-nuget / UoN.ExpressiveAnnotations.NetCore

Annotation-based conditional validation library.
Other
29 stars 12 forks source link

AssertThat selectedlist > 0 on client side #28

Open martajohnsson opened 5 years ago

martajohnsson commented 5 years ago

I have a problem with client side validation. I want to AssertThat selectedlist != null && selectedlist > 0 It works fine on the server side but fails on the client. Should I use ArrayParser or do I have to modify that and write my own parser somehow?

[Required] [AssertThat("SelectedTypes != null && IntListLength(SelectedTypes) > 0", ErrorMessage = "Minst en typ måste väljas")] [ValueParser("ArrayParser")] public List<int> SelectedTypes { get; set; }

I did add customtoolchain as well (it was failing on the server side otherwise): Toolchain.Instance.AddFunction<List<int>, int>("IntListLength", list => list.Count);

Anyone who knows what I should do and can push me into the right direction?

Best regards MJ