symfony - Can I generate validation rules by @ORM annotations? -


consider doctrine entity

class product  {      /**       * @orm\column(type="string", length=24, nullable=false)       */      private $title; } 

can somehow generate @asserts annotations @orm annotations. after generation have class.

class product  {      /**       * @assert\notblank()       * @assert\length(max="24")       *       * @orm\column(type="string", length=24, nullable=false)       */      private $title; } 

you can't automatically. possible create custom generator it.

alternatively, can create custom validator validate entity based on orm mapping;


Comments