GithubHelp home page GithubHelp logo

dimitribouteille / symfony-constraints Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 1.0 18 KB

Contient un ensemble de contraintes de validation (latitude, longitude, uniqueEntity, ...) pour Symfony 4

Home Page: https://packagist.org/packages/dbout/symfony-constraints

License: MIT License

PHP 100.00%
php7 symfony symfony4 validator constraints symfony-service

symfony-constraints's Introduction

Symfony Constraints

Contient un ensemble de contraintes de validation pour Symfony 4.

Installation

composer require dbout/symfony-constraints

Contraintes

  • Latitude Permet de valider une latitude. La latitude doit être comprise en -90deg et 90deg.

      /**
       * @Dbout\SfConstraints\Validator\Constraints\Latitude()
       */
      private $latitude;
    
  • Longitude Permet de valider une longitude. La longitude doit être comprise en -180deg et 180deg.

      /**
       * @Dbout\SfConstraints\Validator\Constraints\Longitude()
       */
      private $longitude;
    
  • NotHtml Permet de valider une chaine ne contenant pas de code html.

      /**
       * @Dbout\SfConstraints\Validator\Constraints\NotHtml()
       */
      private $description;
    
  • Password Permet de valider un mot de passe.

      /**
       * @Dbout\SfConstraints\Validator\Constraints\Password()
       */
      private $plainPassword;
    
  • Phone Permet de valider un numéro de téléphone au format français.

      /**
       * @Dbout\SfConstraints\Validator\Constraints\Phone()
       */
      private $phone;        
    
  • Username Permet de valider un pseudo qui doit être compris entre 3 et 25 caractères et ne contenir que des letters, des chiffres ou _.

      /**
       * @Dbout\SfConstraints\Validator\Constraints\Username(message="Le pseudo doit être compris entre 3 et 25 caractères et non doit contenir aucun caractères spécial")
       */
      private $username;
    
  • PostalCode Permet de valider un code postal au format français

      /**
       * @Dbout\SfConstraints\Validator\Constraints\PostalCode()
       */
      private $postalCode;
    
  • UniqueEntity Permet de valider l'unicité d'une entitée selon une propriéte. Cette contrainte est similaire à la contraite UniqueEntity de Doctrine, à la seule différence que cette contrainte peut-être vérifier à l'extérieur d'un formulaire par le service ValidatorInterface.

       /**
        * @Dbout\SfConstraints\Validator\Constraints\UniqueEntity(message="Un compte existe déjà avec cette adresse email.")
        */
       private $email;
    

    L'utilisation de cette contrainte nécessite l'injection du service @doctrine.orm.entity_manager.

     services :
          
          ....
      
          Dbout\SfConstraints\Validator\Constraints\UniqueEntityValidator:
             arguments: ['@doctrine.orm.entity_manager']
             tags:
             - { name: validator.constraint_validator }
    

symfony-constraints's People

Contributors

dimitribouteille avatar

Stargazers

 avatar

Forkers

sounboul

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.