asisteam/mvcr-document-validator

MVCR 文档验证 API 通信实现

v1.2 2020-05-06 09:39 UTC

This package is auto-updated.

Last update: 2024-09-06 19:19:36 UTC


README

Build Status Licence Downloads this Month Downloads total Latest stable PHPStan

致谢

开发由 AsisTeam s.r.o. 支持。欢迎使用和贡献。

Asisteam

安装

composer require asisteam/mvcr-document-validator

版本

概述

本包与 MVČR API 通信,检查给定的文档是否在已注册的无效文档中。创建 Validator 客户端实例,并通过传入给定的 Document 实体调用其 validate 方法。

以下文档类型可以验证:

  • 捷克共和国个人身份证
  • 捷克共和国护照(中央或地区颁发)
  • 捷克共和国枪支许可证

原始 MVČR 文档可在此处找到: https://www.mvcr.cz/clanek/neplatne-doklady-ve-formatu-xml.aspx

用法

首先创建 Document 对象和 Validator 实例,并将 Document 传递给 Validatorvalidate 方法,该方法返回 ValidatorResult 对象。使用 ValidatorResult,您可以验证给定的文档是否在 MVČR 注册中被标记为无效。此外,您还可以获取文档被添加到注册的时间以及注册本身最后更新的时间。

请使用 DocumentType 枚举来指定文档类型。

$document = new Document('123456AB', DocumentType::PERSONAL_ID_CARD);
$response = (new Validator())->validate($document);

// true if given document was found in registry of invalid documents
$response->isInvalid();

或者,您可以将它配置为 Nette 框架依赖注入服务

extensions:
	mvcr.doc_validator: AsisTeam\MVCR\DocumentValidator\Bridges\Nette\DI\ValidatorExtension
	
mvcr.doc_validator:
	timeout: 5

如果在请求 API 或解析响应的过程中出现任何问题,则会抛出 ResponseException