承接 sllh/iso-codes-validator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sllh/iso-codes-validator

Composer 安装命令:

composer require sllh/iso-codes-validator

包简介

Symfony validator wrapper of ronanguilloux/isocodes

README 文档

README

Symfony validator wrapper of IsoCodes project.

Latest Stable Version Latest Unstable Version License Dependency Status Reference Status

Total Downloads Monthly Downloads Daily Downloads

Build Status AppVeyor Status Scrutinizer Code Quality Code Climate Coverage Status SensioLabsInsight

Installation

First of all, you need to require this library through composer:

$ composer require sllh/iso-codes-validator

After this, you can use it as is.

If you are using it on a Symfony project, you should read the following instructions for a better integration.

As a Symfony bundle

If your project is not using Symfony Full Stack, you must add the following dependencies:

$ composer require symfony/dependency-injection symfony/http-kernel symfony/finder

Translations

If you wish to use default validator messages translations in this bundle, you have to make sure you have translator enabled in your config.

# app/config/config.yml

framework:
    translator: ~

Enable the bundle

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new SLLH\IsoCodesValidator\Bridge\Symfony\Bundle\SLLHIsoCodesValidatorBundle(),
    );
}

Usage

IsoCodesValidator is based on Symfony Validator library.

Manual usage

Create and use IsoCodes constraints by using the Symfony Validation class:

use Symfony\Component\Validator\Validation;
use SLLH\IsoCodesValidator\Constraints\Vat;

$validator = Validation::createValidator();

$violations = $validator->validateValue('DE123456789', new Vat());

With annotations

Validation of objects is possible using "constraint mapping". With such a mapping you can put constraints onto properties and objects of classes. Whenever an object of this class is validated, its properties and method results are matched against the constraints.

use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Constraints as Assert;
use SLLH\IsoCodesValidator\Constraints as IsoCodesAssert;

class Company
{
    /**
     * @Assert\NotBlank
     * @IsoCodesAssert\Siret
     */
    private $siret;

    /**
     * @Assert\NotBlank
     * @IsoCodesAssert\Siren
     */
    private $siren;

    /**
     * @IsoCodesAssert\Vat
     */
    private $vat;

    /**
     * @IsoCodesAssert\ZipCode(country = "FR")
     */
    private $zipCode;

    public function __construct($siret, $siren, $vat, $zipCode)
    {
        $this->siret = $siret;
        $this->siren = $siren;
        $this->vat = $vat;
        $this->zipCode = $zipCode
    }
}

$validator = Validation::createValidatorBuilder()
    ->enableAnnotationMapping()
    ->getValidator();

$company = new Company('48853781200015', '432167567', 'DE123456789', '59000');

$violations = $validator->validate($company);

Constraints reference

Constraints classes can be found on src/Constraints.

All works "as is" without any options unless message.

Only ZipCode constraint accept a country option to limit validation ('all' by default).

Please note that some IsoCodes classes are already implemented on Symfony Validator component. It's up to you to decide which one to use.

If you think an IsoCodes class is missing, feel free to open an issue or make a PR.

License

This bundle is under the MIT license. See the complete license on the LICENSE file.

TODO

sllh/iso-codes-validator 适用场景与选型建议

sllh/iso-codes-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 302.46k 次下载、GitHub Stars 达 38, 最近一次更新时间为 2015 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「validator」 「ISO codes」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sllh/iso-codes-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sllh/iso-codes-validator 我们能提供哪些服务?
定制开发 / 二次开发

基于 sllh/iso-codes-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 302.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 40
  • 点击次数: 24
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 38
  • Watchers: 3
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-20