This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I've got an entity which has a bunch of required properties. all validation happens fine, errors appear in collection, yada yada. problem is that the presencerequired messages are all the same - "A value is required.". Not good for displaying in a UI. I noticed that presencevalidationrule has a property where i should be able to set the message with a string format - in which case I could insert the name of the property. question - can i globally set that property for presencevalidationrule? I see the validatepresenceattribute type has a message property on it but of course this attribute doesn't allow multiple and it's all sitting on the LS generated code. i can see a couple of options;
cheers justin |
|
|
You can set the custom message in the designer by going to the LightSpeed Model Explorer (View > Other Windows > LightSpeed Model if it's not already lurking behind Solution Explorer or something like that), expanding the entity, expanding the Validations folder, and selecting the validation that you want to set a custom message on. You will then find Custom Message in the Properties window. We don't have a way for you to set this message globally, except possibly by localising the LightSpeed resources and shipping them as a satellite DLL (and I haven't tested this to see if it will work if the satellite DLL is for the default culture). Sorry. |
|
|
ok, fair enough. would you consider then either making it static-settable, config-settable, or changing the default message to include the name of the property (though i guess that would break backwards-compat?)... cheers justin
|
|
|
I've logged a feature request for this, though we'd need to have a think about possible APIs, otherwise there's a danger that custom message configuration options could overwhelm the more common and important configuration options -- that's why it's not in the Properties window in the designer, we didn't want the Properties window to get clogged up with "Xxx Validation Custom Message" properties! |
|
|
this is related, which is why i've put it into the same thread...
no problems with custom error messages for properties. but - what about error messages for relationship violations? i've got a 1-Many non-nullable relationship between A and B. When i update A via a modelbinder (using MVC here), it tries to set the backreference to null - falls over and adds an error to the entity state. That's all good except when i get the error message out it says "A value is required." I would really like to customise this message to show the name of the backreference. Is this possible? cheers justin |
|
|
I don't believe it's possible, because I don't believe the message is coming from a validation (the designer doesn't generate validations on FKs). I am also a bit puzzled as to the exact setup here -- I am probably being a bit of a dullard here, but if you have a non-nullable relationship and you're setting the B.A backreference to null, that effectively removes B from the UOW in my tests (since it depends on its parent to survive, but no longer has one). So I haven't managed to reproduce the behaviour you're describing in order to confirm whether it's possible to change the message or not. Could you perhaps provide a little more detail on how your model is set up and what you are doing that triggers the error? Thanks! |
|
|
sorry, been away. i think this message came from the fact I was (in the MVC ModelBinder) trying to set AssociationId to null when it was not nullable. The error message actually comes from MVC and looks as though it has been addressed in MVC RC2 - will post back if not. so - it's not a LS error msg being generated but an MVC thing... cheers |
|