So I've been playing around with Hotchocolate lately and I made a class which gives me back a list of students, but I want to have some validation functions for it. I didn't really find anything that helps me from the official hotchocolate website.
Student.cs
public class Student
{
[GraphQLNonNullType]
public string Name{ get; set; }
[GraphQLNonNullType]
public string LastName{ get; set; }
[GraphQLNonNullType]
public string Picture { get; set; }
}
This is my query, which currently gives me back all students from a list.
StudentQuery.cs
public class StudentQuery
{
[UseFiltering]
[UseSorting]
public List<Student> GetStudents()
{
return MongoDBHelper.LoadRecords<Student>(EMongoCollection.Students);
}
}
Now my question is, how can I make a ValidationRule for a student, saying for example that a student has to at least have 3 characters for his name? Could someone be kind enough to provide me some example?
Thanks in advance.