hi,
awesome library, but could you tell me please how to validate the following
```
public class Product
{
public string Id { get; set; }
public List<Attribute> Attributes { get; set; }
}
public class Attribute
{
public string Name { get; set; }
public string Value { get; set; }
}
var person = new Person();
person.Attributes.Add("price","10");
```
how can i validate that price attribute is no more than 5 for example.
thanks in advanced.
Comments: You could define a custom rule against the Attributes property using a Must validator: ``` public class ProductValidator : AbstractValidator<Product> { public ProductValidator() { RuleFor(x => x.Attributes).Must(HaveValidPrice); } bool HaveValidPrice(List<Attribute> attributes) { var priceAttribute = attributes.Single(x => x.Name == "price"); return int.Parse(priceAttribute.Value) <= 5; } } ```
awesome library, but could you tell me please how to validate the following
```
public class Product
{
public string Id { get; set; }
public List<Attribute> Attributes { get; set; }
}
public class Attribute
{
public string Name { get; set; }
public string Value { get; set; }
}
var person = new Person();
person.Attributes.Add("price","10");
```
how can i validate that price attribute is no more than 5 for example.
thanks in advanced.
Comments: You could define a custom rule against the Attributes property using a Must validator: ``` public class ProductValidator : AbstractValidator<Product> { public ProductValidator() { RuleFor(x => x.Attributes).Must(HaveValidPrice); } bool HaveValidPrice(List<Attribute> attributes) { var priceAttribute = attributes.Single(x => x.Name == "price"); return int.Parse(priceAttribute.Value) <= 5; } } ```