Using EMF Validation to validate model I get error messages such as
The feature 'blah' of 'blah' with 0 values must have at least 1 values
This message might be confusing to user, is there anyway I can override this error message for particular element/attribute with custom message? In a schema perhaps?
We have done this by adding a new fragment for org.eclipse.emf.ecore with our new message texts in the file plugin_en.properties. These will take precedence over the texts in plugin.properties...
Related
I want to use custom error messages for validation constraints on dozens of fields in my project.
I do not want to set the message on every one of these, because that would be a blatant violation of DRY. Repeating the same string in every declaration like: #NotNull(message="custom msg") would mean that if I decide to change the message in the future I'd have to hunt them all down replace them, but even worse I might use the wrong string on some of them and be inconsistent.
How do you deal with this?
Is the best option really to extend every symfony stock constraint and set my default there, and use my own custom annotation class?
Please note that using the translator is not an option for me, so I am looking for a solution that does not include the symfony translation component.
Thanks a lot for the help in advance.
Assuming you are working with English as the app's language, and you've configured translator: { fallback: en }, you can override these constraint messages universally. Start by creating this file: app/Resources/translations/validators.en.yml
And use the following translation format:
This value should not be blank.: Your custom message here
Whatever the standard message is.: Another custom message
This also works for any other language setting, assuming you've made a validators.lang.yml for it!
You can also place this file in your bundle directory under Resources/translations, and a few other places.
You can read more about this here!
Good evening all,
Writing an application in IronPython that will act as a message spoofer for a system that has not been developed far enough to test for our system. Part of the application is a set of tables that show values for messages and commands. In the case of commands there are some fields of our commands that have enum values. The command table is to have a drop-down box with those enum options in it.
My approach is to create a DataSet for each of our messages. The DataSet has a DataTable that had the message fields in it and the message values. It also has a table for each enum type in the message. So, the following code is what I use to figure out if the field is a normal field or an enum field.
msg = mpas.M120()
msg_fields = msg.DESCRIPTOR.fields
for field in msg_fields:
fieldEnumType = msg.DESCRIPTOR.fields_by_name[field.name].enum_type
print("{} --> EnumType: {}".format(field.name, fieldEnumType.name if fieldEnumType != None else 'None'))
I have also found that this works for me as well:
msg = mpas.M120()
msg_fields = msg.DESCRIPTOR.fields
for k,v in msg.DESCRIPTOR.fields_by_name.items():
print ("{} --> {}".format(k, ((v.enum_type).name if v.enum_type != None else 'None')))
What I will get from this is the name of the enum for each of the enum fields. I now want to be able to get a list of all of the values for each of the enum fields found. Here is the trick, enums that are used by a certain message and only that message are defined at the message level (i.e. mpas.M120().. Enums that are used by other messages are defined at the top level (i.e. mpas..
So, how would I go about finding the values for these enums so I can populate my drop-down boxes? I have been working on this for the better part of a day now and I cannot figure it out.
Thanks in advance...
You've already found v.enum_type, which is the EnumDescriptor corresponding to the field's enum type. You are getting name from here, but this object also contains a list of values. See the documentation here:
https://developers.google.com/protocol-buffers/docs/reference/python/google.protobuf.descriptor.EnumDescriptor-class
I have a webpage which picks up questions from a database and ask users to give an Yes/No questions and sometimes based on the question they have to select a dropdown list or a text to enter.
I need to mark the fields which are missing or invalid data is entered. All the fields are mandatory so I am using setRequired(true); and using Abstract behaviour class, I am adding a border to highlight the formcomponent ( Check Box or Dropdownlist) if it has any errors. If any fields are missing or invalid , I am displaying a generic error message - Invalid or missing data! Please review the fields marked in red colour.
I cannot display error messages next to the fields as I have less space around the component on the page.
I have achieved it by using a feedbackfilter for the Form and overriding the onError() method of the Form. Since the feedback messages of formcomponents are not rendered on a feedbackpanel, I am getting the following warning in the console.
WARN WebSession : Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page. Message: [FeedbackMessage message = "Field 'L2' is required.", reporter = L2, level = ERROR]
Is there a way we can get rid of the messages and still retain the formcomponent as invalid ( FormComponent.isVallid() ) and a clean log files ?
I have tried clearing the feedback messages from session but it has an impact on the FormComponent Valid status.
I am on Wicket 1.5
Make the feedback panel persistent invisible - there can be any messages and it still should not appear ...
Breeze's default validation messages use the database field name as part of the displayed error message; such as, "EmpTeleNo is required". Obviously, this probably shouldn't end up in the production version of our software.
But as we approach delivery of our software, it was hoped that this might be fixed, perhaps by inspecting the "Display" attribute from the model or something like that. As far as I can tell, this issue still remains.
Has this problem been resolved or has anyone figured out a work-around?
Thanks.
This is not YET well documented but you can simply set the 'displayName' property on any dataProperty and this will override the autogenerated display name and will be used for all validation messages for this property. So
var custType = myEntityManager.metadataStore.getEntityType("Customer");
var dp = custType.getProperty("companyName");
dp.displayName = "My custom display name";
Also, see the "Customize the message templates" topic at the bottom of this page: http://www.breezejs.com/documentation/validation.
There is also an item on the Breeze User Voice that requests something very similar to what you are asking for. Please vote for it.
https://breezejs.uservoice.com/forums/173093-breeze-feature-suggestions
A related problem that is specific to single field has been solved here. But how to customize a collection field's conversion error message?
Here is an example:
On a jsp page, I have a field in Collection type:
...
<s:iterator value="items" status="m">
<s:hidden name="selitmems[%{#m.index}].id" value="%{id}"/>
<s:textfield name="selitmems[%{#m.index}].quant" size="10"/>
</s:iterator>
The items' type is: List<Item>; the selitems' type is List<SelItem>.
I want selitmems[].quant property to be an integer type. If a string like "abc" is filled in for the first item by an end user, the default error message is:
Invalid field value for field "selitmems[0].quant".
The above message is not what i want. In my case, I would prefer to generalize the error message as follows regardless of the specific selected item:
Please input integers for the items.
Of course it would be great if the error message can vary according to the specific item:
Please input an integer for the first item.
I have tried to add some keys like "selitmems[0].quant" or "selitmems" in the properties file, but can't get the result. Is there way to customize the error message for a collection field in struts2 when I can still reuse the built-in type conversion functions?
Try using the "label" attribute. You can play some... interesting games with this, such as (untested, but close):
label="%{getText('selitem.quantity', { #m.index })}"
The property file would contain:
selitem.quantity=Item #{0}
You can change the conversion error message as described here, although this may not be precisely what you want to do.
(I've been known to remove the conversion interceptor altogether and let either the default converters or custom converters handle conversion errors when a bad conversion also fails the field's "real" validation.)
Mm hmm... you can play some crazy games with OGNL and substituion.
Put something like this in your properties file.
invalid.fieldvalue.selitmems.quant = Please input integers for the items.
Then selitmems[0].quant, selitmems[1].quant, selitmems[2].quant conversion errors all return the same message.