简体   繁体   中英

Symfony2 Validator fatal error

I created a symfony bundle that worked when I created it, but when I moved it somewhere else it gave me the folowing error:

Fatal error: Class 'Symfony\\Component\\Validator\\Constraints\\type' not found in /home/nagel/sites/battlemamono/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php on line 63

this is a validator error and the only Validator I hve is this:

Battlemamono\DatabaseBundle\Entity\Mamono:
    constraints:
        - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: 
            fields: name
            message: A mamono with this name already exists.
            groups: [creation]
properties:
    id:
        - type: integer

    name:
        - NotBlank: ~
        - MaxLength: 30
        - type: string

    family1:
        - NotBlank: ~
        - MaxLength: 30
        - type: string
        - Choice : { callback: getFamily }

    family2:
        - MaxLength: 30
        - type: string
        - Choice : { callback: getFamily }

    element1:
        - NotBlank: ~
        - MaxLength: 30
        - type: string
        - Choice : { callback: getElements }

    element2:
        - MaxLength: 30
        - type: string
        - Choice : { callback: getElements }

    disposition:
        - NotBlank: ~
        - MaxLength: 100
        - type: string
    diet:
       - NotBlank: ~
       - MaxLength: 100
       - type: string

    previousForm:
       - MaxLength: 30
       - type: string

    nextForm:
       - MaxLength: 30
       - type: string

    evolution:
       - MaxLength: 30
       - type: string

    evolutionLove:
      - type: bool

    tags:
      - type: string
      - MaxLength: 100

    description:
     - type: string
     - NotBlank: ~

I dont know why it does this.

You have it in wrong format, this is what the doc says:

Acme\BlogBundle\Entity\Author:
    properties:
        age:
            - Type:
                type: integer
                message: The value {{ value }} is not a valid {{ type }}.

from http://symfony.com/doc/current/reference/constraints/Type.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM