Let's extract all this logic into separate function like validateJsonSchema?