 
   return .valid
 }
+
+
+extension Sequence where Iterator.Element == ValidationError {
+  func validationResult() -> ValidationResult {
+    let errors = Array(self)
+    if errors.isEmpty {
+      return .valid
+    }
+
+    return .invalid(errors)
+  }
+}

import Foundation


public enum ValidationResult {
  case valid
  case invalid([String])

  return validatePropertiesLength(maxProperties, comparitor: >=, error: "Amount of properties is greater than maximum permitted")(instance)
}

func requiredSequence(validator: Validator, required: Any, instance: Any, schema: [String: Any]) -> AnySequence<String> {
  guard let instance = instance as? [String: Any] else {
    return AnySequence(EmptyCollection())
  }

  guard let required = required as? [String] else {
    return AnySequence(EmptyCollection())
  }

  return AnySequence(required.lazy.compactMap { key -> String? in
    guard !instance.keys.contains(key) else { return nil }
    return "Required property '\(key)' is missing"
  })
}

func required(validator: Validator, required: Any, instance: Any, schema: [String: Any]) -> ValidationResult {
  return requiredSequence(validator: validator, required: required, instance: instance, schema: schema).validationResult()
}

func dependentRequired(validator: Validator, dependentRequired: Any, instance: Any, schema: [String: Any]) -> ValidationResult {
