Saturday, 15 August 2015

doctrine2 - Using column length to validate -



doctrine2 - Using column length to validate -

/** * @column(type="string", length=10) */ protected $name;

what purpose of 'length'?

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/annotations-reference.html#annref-column

at above url states: "length: used 'string' type determine maximum length in database. doctrine not validate length of string values you."

i have length defined in database, point of adding 'length' in doctrine? 'length' have anything validation?

the thing can figure out cuts off excess characters before trying insert database. annoying when want exception or error.

thanks :d

doctrine not apply kind of validation on entities: loads , saves info applying required type conversions (and fails if wrong objects).

the length attribute there aid during schema generation when utilize doctrine's schema tools.

you can still extract value metadata api of doctrine 2 orm eventually, consider using proper validation library such tasks.

doctrine2

No comments:

Post a Comment