Skip to content

Implement IsValid() overloads with list of errors for IGridifyQuery and IGridifyOrdering #332

@Evlantiya

Description

@Evlantiya

Details

In v2.18.0 was added IsValid(out List validationErrors) overloads for IGridifyFiltering with detailed error messages.

It works well, but only for Filter part of query. On top of that, interface IGridifyQuery inherits both IGridifyFiltering and IGridifyOrdering.

This can be quite misleading, and can be reason for runtime errors.

For example, developer might not notice that this overload works with IGridifyFilterig interface, and write something like that

using System;
using Gridify;

var mapper = new GridifyMapper<Person>()
    .AddMap("Name", x=>x.name)
    .AddMap("Age", x=>x.age);

var badOrderByQuery = new GridifyQuery(1,100,"Name=Ivan","ageee");

Console.WriteLine(badOrderByQuery.IsValid(out var errors, mapper)); //True
Console.WriteLine(badOrderByQuery.IsValid(mapper));                 //False

record Person(string name, int age);

This is pretty counterintuitive from DevEx point of view.
I looked for other overloads but found nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions