validation - Doctrine: Validate Model Data using Annotations -
in doctrine, there way validate model data using annotations? bellow example in c#
public class productmd { [stringlength(50),required] public object name { get; set; } [stringlength(15)] public object color { get; set; } [range(0, 9999)] public object weight { get; set; } }
so when property name empty give error.
unfortunately, starting doctrine2 there no validation component integrated orm anymore.
if, example, you're using doctrine2 symfony2, can take advantage of validation framework component using @assert
annotations in doctrine entities.
if don't use framework, or if framework use not provide validation component, can use doctrine's lifecycle callbacks provide custom validation in @prepersist
, @preupdate
(for more information, take here). in case, there's more manual work done still sounds reasonable solution.
Comments
Post a Comment