Symfony validation with dynamic message - validation

I have been looking around and was wondering if it is possible to validate a form but dynamically add error message.
For example:
Test\TesterBundle\Model\Products:
constraints:
- Propel\PropelBundle\Validator\Constraints\UniqueObject:
fields: [Url, SKU, Title]
message: Field already exists
This if the Url isn't unique it will output Field already Exists. However, it doesn't state which field already exists.
My first thought was to use [fields] inside the message which through an error:
Test\TesterBundle\Model\Products:
constraints:
- Propel\PropelBundle\Validator\Constraints\UniqueObject:
fields: [Url, SKU, Title]
message: [fields] already exists
I then tried a simple %s to see if it already inserted this but just output the string.
Is there an already created method, would I need to extend the UniqueObject Constraint and create a new one that outputs the field name aswel, or would I need to create a new function to do this?

Related

Oracle NoSQL Error : [ILLEGAL_ARGUMENT] PUT: Illegal Argument: Value should not be set for a generated always identity column: id

I’m trying to update a row with the Node sdk and I keep getting Error: NoSQLArgumentError: [ILLEGAL_ARGUMENT] PUT: Illegal Argument: Value should not be set for a generated always identity column: id.
What am I doing wrong here?
async function update(id, data, table)
{
var timestamp = new Date
res = await client.putIfPresent(table, {
id: id,
last_modified: timestamp,
json_document: data
})
}
I've created this "Answer your own question" because the first time dealing with this error, I've decided to change ALL my code in order to use the SQL API and so use the UPDATE command. I was thinking that it was the only solution
It appears that you have created a table with an identity column for the field "id" and that you used "generate always." In this case, when you perform a put operation there must be no value set for "id" or you will get this error. Further, if you are trying to update (vs create) an existing row with an identity column you cannot use put() at all but must instead use an update query
In fact, We can use the command putIfPresent if the table was created using generate by default. In this case, the previous constraints will not apply
Oracle NoSQL supports the following options :
GENERATED ALWAYS AS IDENTITY
GENERATED BY DEFAULT AS IDENTITY
GENERATED BY DEFAULT ON NULL AS IDENTITY
Depending your requirements, this is interesting to know

Change a field property in SNOW

I'm trying to change a field's default property in SNOW. Here in incidents we've a field Assigned to and it accepts some default values. But instead of that I want it to accept any values (Integer, String, Special characters etc). In my SNOW Form lay out tried the below.
Created a new String field, Named it as Assigned to Label and name as assigned_to and saved it and it ended up as shown below.
and when I added some random text in this field, it gave me the below error.
please let me know on how can I change this field to accept any string as Input.
Thanks
You are referencing the sys_user table on the form field Assigned to. You need to provide the value for the Assigned to field the sys_id from the User record.
Providing it with any text will result in an invalid reference since it is looking for the unique sys_id on the user table.

Nested for loop and filter query with parent field does not work with Microsoft flow

I am new to Microsoft dynamics & flow, I have following schema
Course
Id - Primary key
Title - Title of the course
Date - Course date field
Participant
Id - Primary key
CourseId - Course id foreign key(From Course relation)
First Try
I would like to filter based on date so I use List records action and I just loop through each course to get participants(List records action) and then I need to again loop through participants so that I need to send them email about the course. The problem is nested loop is not supported.
Alternate tryout
Instead of querying Course, I use List records action to get all the participants with course date in Course. This is just a join and where condition. But this also doesn't help.
This is the error I am getting The Property (0) is not a primary key of the related entity
In Filter Query I have Course/Date gt #{utcNow()} which throws above error but course/Id eq 12-321-23123-12332` works but useless.
Anything else I can tryout?
This case is mentioned in a limitations list, but, for some reasons, MSDN has another error message for the same case
Can't filter queries based on the value of a single-valued navigation property
"message": "The query node (0) is not supported",
As an alternative try to use FetchXml for this specific case

Get error values of fields

I wanted to get the error values for the names of all the fields in my form. I wanted to show a "form-level" error saying "you need to go look at this field" and clicking individual messages will scroll them to that field.
I haven't been able to figure out how to get anything other then the "form-level" error from this.props.error.
I had a similar requirement and I used getFormSyncErrors selector which returns an object whose keys are the name of the invalid fields and whose values are the corresponding error:
{
recipientAddress: "Required",
recipientCity: "Required",
recipientZip: "Required"
}

Magento - import attribute with custom source model

I'm running into a problem with importing product attribute values that has custom source model (so no visible options in attribute edit page).
Simply it's not working with option ID value or option label neither.
When I was trying to export product with this attribute, there has been an error
Invalid option ID specified for ceneo_category_id (2278), skipping the record. (Line 1, SKU: ...)
Can someone help me with this?
I think I've just experienced the same problem:
created a custom multiselect attribute with a custom source model
for a product.
the label was 'human readable' and the value was an alphanumeric
code.
used the alphanumeric code in a csv product import file.
tried to use the Magento import to load a product with this
attribute.
Got the error: Invalid value for 'test_attr' in rows: 1
After some debugging this seems to be because:
- Mage_ImportExport_Model_Import_Entity_Abstract#isAttributeValid(..) reports the attribute value is invalid (the case 'multiselect' line).
- this is because it is checking the value from the csv file (alphanumeric code) and finding it wasn't in the list of valid options for this attribute. This is because its list of valid options contained the label.
- The reason the list of options contains the label and not the value/code is because in Mage_ImportExport_Model_Import_Entity_Abstract#getAttributeOptions(..) it decides to use the label because the attribute isn't in an array of attributes that values should be used for. This array is declared in Mage_ImportExport_Model_Import_Entity_Abstract:
protected $_indexValueAttributes = array(
'status',
'tax_class_id',
'visibility',
'enable_googlecheckout',
'gift_message_available',
'custom_design'
);
So, the answer is to use in the csv file the label for the attribute. Or to overwrite Mage_ImportExport_Model_Import_Entity_Abstract to get your attribute into the array of attributes for which the value and not the label is expected during product imports.

Resources