public void TypeConstraintDerived(bool input) { var message = Guid.NewGuid().ToString(); var builder = new ValidatorBuilder <object>(); var constraintId = Guid.NewGuid().ToString(); builder.AddTypeConstraint <SimpleBoolean>((c, ctx) => { if (!c.IsTrue) { ctx.RaiseError(message); } }, constraintId); var validator = builder.Build(); var context = new TestValidationContext(); validator.Validate(new SimpleBooleanDerived { IsTrue = input }, context.Context); if (input) { Assert.Empty(context.Errors); } else { var error = Assert.Single(context.Errors); Assert.Equal(constraintId, error.Id); Assert.Equal(message, error.Message); } }