The Wayback Machine - https://web.archive.org/web/20210120064801/https://github.com/marcw/validator
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
src
 
 
 
 
 
 
 
 
 
 

README.md

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 Blacklist. 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.

About

Symfony Validators for: Subdomain validation, Username, GA Tracker ID, SMS Message, HTML Color,

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.