【问题标题】:Symfony2 Validator fatal errorSymfony2 验证器致命错误
【发布时间】:2013-01-17 16:00:00
【问题描述】:

我创建了一个 symfony 包,当我创建它时它可以工作,但是当我将它移到其他地方时,它给了我以下错误:

致命错误:在 /home/nagel/sites/battlemamono/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader 中找不到类“Symfony\Component\Validator\Constraints\type”。第63行的php

这是一个验证器错误,我拥有的唯一验证器是:

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: ~

我不知道为什么会这样。

【问题讨论】:

    标签: php symfony yaml


    【解决方案1】:

    你的格式有误,文档是这样说的:

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

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

    【讨论】:

    • 谢谢,确实如此,但在我编写代码的另一台计算机上它可以工作。奇怪。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    • 2013-05-08
    • 1970-01-01
    • 2015-09-03
    相关资源
    最近更新 更多