Add option to validate entities loaded from a file by Fixtures.load

Bug #603843 reported by AMcBain
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
New
Undecided
Unassigned

Bug Description

Currently Fixtures.load will take in entities from a given file as-is. This means that entities which may normally not validate are loaded into the database. This is a problem because (at least for me) it's fairly easy for me to forget a line for an entity, and I'd like to know at the time it's loaded I oopsed, not when one of my app pages blows up because a required field was null.

Therefore I've attached a patch that validates an entity after it is loaded and throws an error containing the entity type, id, and error messages if it fails. Considering that not everyone might want this and for backwards compatibility, this feature does not run by default and can be turned on by putting "fixtures.validate=true" in the application.conf file.

As to my patch, if there's a better way within Play! of figuring out whether a conf-file value is true, please feel free to change that. I couldn't see a nice way other than simple String comparison as the closest solution would have been getBoolean("fixtures.validate", false) if Play.configuration is was a play.utils.Properties not a java.util.Properties instance.

Revision history for this message
AMcBain (mcbain-asm) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.