Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: No service registered for QueryValidator #9

Closed
bpkinez opened this issue Feb 28, 2018 · 2 comments
Closed

Issue: No service registered for QueryValidator #9

bpkinez opened this issue Feb 28, 2018 · 2 comments

Comments

@bpkinez
Copy link
Contributor

bpkinez commented Feb 28, 2018

Hi Benjamin,

when I have class User without UserQueryValidator part like:

    public class User
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public DateTime DateOfBirth { get; set; }

        public IEnumerable<UserRole> UserRoles { get; set; }

        public User() { }

        public User(string firstName, string lastName, DateTime dateOfBirth)
        {
            FirstName = firstName;
            LastName = lastName;
            DateOfBirth = dateOfBirth;
        }
    }

and call http://localhost:{port}/api/user i get exception RuntimeException: No service registered for QueryValidator: Delve.Models.Validation.IQueryValidator`1[Delve.Demo.Models.User], but I don't want to have any query validation on User class in this case.

@bbartels
Copy link
Owner

bbartels commented Mar 1, 2018

This is a limitation right now, there is no way for you to use an Entity without an Entity validator.
So I would just suggest creating a validator for the User entity and call AllowAll on each property.

Also I don't think I'll change this going forward, because adding a QueryValidator to an entity implies intent. So if you accidentally forget to add one I don't think it would be good to automatically expose all properties to be filtered selected and sorted.

I may however add an overload to AllowAll() at some point that will automatically add all native properties to be filtered, sorted and selected.

@bpkinez
Copy link
Contributor Author

bpkinez commented Mar 1, 2018

Ok, thanks.

@bpkinez bpkinez closed this as completed Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants