Giter Club home page Giter Club logo

validator's Introduction

Validator

Build Status Coverage Status SensioLabsInsight

Some additions to the Validator Symfony Component.

Subdomain validation

Validate a string value based on these rules:

  • Be not null.
  • Be not blank.
  • Be more than or equal to 3 characters.
  • Be less than 63 characters.
  • Be in alphanumeric and hyphen.
  • Do not start with an hyphen.
  • Do not end with an hyphen.

Username validation

Validate a string value based on The Big Username Blocklist. It won't validate if the value is equal to one of these terms.

GoogleAnalytics Tracker ID validation

Validate that a string matches the correct format for a Google Analytics Tracker ID.

SMS Message Validation.

Validate that a value fits in one (or more) SMS message.

HTMLColor validator

Validate that a string matches the basic HTML format for a color (#abc or #abcdef)

Example

<?php

namespace AppBundle\Entity;

use MarcW\Validator\Constraints as Assert;

class User
{
    /**
     * The username is used to attribute a subdomain or a subfolder to the user like:
     * https://username.acme.com or https://acme.com/username
     * @Assert\Subdomain
     * @Assert\Username
     */
    private $username;

    /**
     * @Assert\GoogleAnalytics
     */
    private $googleAnalytics;

    /**
     * @Assert\HTMLColor
     */
    private $backgroundColor;
}

class Message
{
    /**
     * This value must fit in 2 SMS messages.
     *
     * @Assert\SmsMessage(max=2)
     */
    private $body;
}

For more information, please read the Symfony Validator component official documentation.

Install

composer require marcw/validator

Can I contribute?

Sure! Feel free to report issues, send pull-requests, or ask for help.

LICENSE

See the LICENSE file.

validator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

validator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.