    for field in jsondata['document']:
        try:
            key = field['name']
            value = field['value']

            if key in mandatories:
                mandatories.remove(key)
            else:
                optionals.remove(key)
        except (ValueError, KeyError):
            return False

        try:
            function_dict[key](value)
        except ExceptionValidation as e:
            print(e.code, "->", e.message)
            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_document.json"
    else:
        example_doc_path = argv[1]
    if argc < 3:
        schema_doc_path = "./JSON_Files/schema_document.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)
