    document, op_cont = get_document(jsondata)

    for field in document:
        try:
            key, value = get_field(field, op_cont)

            opt = False
            if field in mandatories:
                mandatories.remove(field)
            else:
                optionals.remove(field)
                opt = True

            try:
                if len(key) == 1:
                    value1 = value[field]
                else:
                    value1 = value

                if opt and value1 is None:
                    continue

                function_dict[field](value1)
            except ExceptionValidation as exc:
                print(exc.code, "->", exc.message)
                return False

        except (ValueError, KeyError):
            return False

    return len(mandatories) == 0


def main(example_doc, schema_doc):
    # json_file = input("Insira o ficheiro com documento em JSON: ")
    document = Document(file=example_doc)
    document_data = document.content

    schema_document = Document(file=schema_doc)
    schema_data = schema_document.content

    v = Verifier(schema_data)
    v.verify(document_data)

    if validate_json_file(document_data):
        print("Documento Válido")
        return True
    else:
        print("Documento Inválido")
        return False


if __name__ == '__main__':
    argv = sys.argv
    argc = len(argv)

    if argc < 2:
        example_doc_path = "../../JSON_Files/mDL_example_document3.json"
    else:
        example_doc_path = argv[1]
    if argc < 3:
        schema_doc_path = "../../JSON_Files/schema_document3.json"
    else:
        schema_doc_path = argv[2]

    try:
        if main(example_doc_path, schema_doc_path):
            exit(0)
    except Exception as e:
        print(e)
        exit(-1)
