     return AnySequence(EmptyCollection())
   }
 
-  if !instance.contains(where: { validator.descend(instance: $0, subschema: contains).validationResult().valid }) {
+  if !instance.contains(where: { validator.descend(instance: $0, subschema: contains).isValid }) {
     return AnySequence(["\(instance) does not match contains"])
   }
 

}

func `if`(validator: Validator, `if`: Any, instance: Any, schema: [String: Any]) -> AnySequence<ValidationError> {
  if validator.validate(instance: instance, schema: `if`).validationResult().valid {
    if let then = schema["then"] {
      return validator.descend(instance: instance, subschema: then)
    }

}

func flatten(_ results: [AnySequence<ValidationError>]) -> AnySequence<ValidationError> {
  let errors = results.reduce([String]()) { (accumulator, failure) in
    return accumulator + Array(failure)
  }

  return AnySequence(errors)
