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

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

func required(validator: Validator, required: Any, instance: Any, schema: [String: Any]) -> ValidationResult {
  guard let instance = instance as? [String: Any] else {
    return .valid
  }

  guard let required = required as? [String] else {
    return .valid
  }

  let errors = required
    .filter { key in !instance.keys.contains(key) }
    .map { "Required property '\($0)' is missing" }
  guard !errors.isEmpty else {
    return .valid
  }

  return .invalid(errors)
}

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

import Foundation

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