ValidateThis EqualTo ClientFieldName JavaScript Validation - coldfusion

The title sucks, I'm sorry.
It takes a little bit to setup my problem, so I'm going to try and simplify it.
My form uses structure notation.
<input type= "text"
name= "bank[routing_number]"
id= "bank_routing_number"
value= "#rc.bank[ "routing_number" ]#"
autocomplete= "off"
maxlength= "9" />
<input type= "text"
name= "bank[routing_number_confirmation]"
id= "bank_routing_number_confirmation"
value= "#rc.bank[ "routing_number_confirmation" ]#"
autocomplete= "off"
maxlength= "9" />
The ValidateThis rules work fine on the server. I'm running on ColdFusion 9.0.1.
The problem I have is the JavaScript code generated by ValidateThis.
This is the JavaScript rule for EqualTo.
fm['bank[routing_number_confirmation]'].rules('add',{"equalto":":input[name='routing_number']","messages":{"equalto":"Bank ACH Routing Numbers (ABA) must match."}}); fm['bank[routing_number_confirmation]'] = $(":input[name='bank[routing_number_confirmation]']",$form_register_new);
The relative bit is this:
":input[name='routing_number']"
I'm expecting this code to be:
":input[name='bank[routing_number]']"
Here are the ValidateThis rules for routing_number and routing_number_confirmation.
{ "name": "routing_number" ,
"clientFieldName": "bank[routing_number]" ,
"rules": [
{ "type": "required" ,
"failureMessage": "Bank ACH Routing Number (ABA) is required."
} ,
{ "type": "rangelength" ,
"params": [
{ "name": "minlength" , "value": "9" } ,
{ "name": "maxlength" , "value": "9"} ] ,
"failureMessage": "Bank ACH Routing Number (ABA) is 9 digits."
}
]
} ,
{ "name": "routing_number_confirmation" ,
"clientFieldName": "bank[routing_number_confirmation]" ,
"rules": [
{ "type": "required" ,
"failureMessage": "Confirm Bank ACH Routing Number (ABA) is required."
} ,
{ "type": "equalTo" ,
"params": [
{ "name": "comparePropertyName" ,
"value": "routing_number" }
] ,
"failureMessage": "Bank ACH Routing Numbers (ABA) must match."
} ,
{ "type": "rangelength" ,
"params": [
{ "name": "minlength" , "value": "9" } ,
{ "name": "maxlength" , "value": "9"} ] ,
"failureMessage": "Bank ACH Routing Number (ABA) is 9 digits."
}
]
}
This is the load order for ValidateThis scripts.
// jQuery and jQuery Validate are loaded.
#getColdboxOCM().get( "ValidateThis" ).getInitializationScript(
JSIncludes= false )#
// Other ValidateThis scripts
#getColdboxOCM().get( "ValidateThis" ).getValidationScript(
objectType= "registration/bank-account" ,
formName= rc.form.name )#
The other JavaScript rules for routing_number and routing_number_confirmation work just fine. I've added some custom rules to get around the issue, but is there a way I can fix this using ValidateThis?

I asked the question on the ValidateThis Google Group and got a prompt response.
http://groups.google.com/group/validatethis/browse_thread/thread/2b18af00d3f5ce98
This was a bug within ValidateThis, but was corrected and is now part of the development branch in github.

Related

GCP - BigTable to BigQuery

I am trying to query Bigtable data in BigQuery using the external table configuration. I have the following SQL command that I am working with. However, I get an error stating invalid bigtable_options for format CLOUD_BIGTABLE.
The code works when I remove the columns field. For context, the raw data looks like this (running query without column field):
rowkey
aAA.column.name
aAA.column.cell.value
4271
xxx
30
yyy
25
But I would like the table to look like this:
rowkey
xxx
4271
30
CREATE EXTERNAL TABLE dev_test.telem_test
OPTIONS (
format = 'CLOUD_BIGTABLE',
uris = ['https://googleapis.com/bigtable/projects/telem/instances/dbb-bigtable/tables/db1'],
bigtable_options =
"""
{
bigtableColumnFamilies: [
{
"familyId": "aAA",
"type": "string",
"encoding": "string",
"columns": [
{
"qualifierEncoded": string,
"qualifierString": string,
"fieldName": "xxx",
"type": string,
"encoding": string,
"onlyReadLatest": false
}
]
}
],
readRowkeyAsString: true
}
"""
);
I think you let the default value for each column attribute. the string is the type of the value to provide, but not the raw value to provide. It makes no sense in JSON here. Try to add double quote like that
CREATE EXTERNAL TABLE dev_test.telem_test
OPTIONS (
format = 'CLOUD_BIGTABLE',
uris = ['https://googleapis.com/bigtable/projects/telem/instances/dbb-bigtable/tables/db1'],
bigtable_options =
"""
{
bigtableColumnFamilies: [
{
"familyId": "aAA",
"type": "string",
"encoding": "string",
"columns": [
{
"qualifierEncoded": "string",
"qualifierString": "string",
"fieldName": "xxx",
"type": "string",
"encoding": "string",
"onlyReadLatest": false
}
]
}
],
readRowkeyAsString: true
}
"""
);
The false is correct because the type is a boolean. More details here. The encoding "string" will be erroneous (use a real encoding type).
The error here is in this part:
bigtableColumnFamilies: [
It should be:
"columnFamilies": [
Concerning adding columns for string you will only add:
"columns": [{
"qualifierString": "name_of_column_from_bt",
"fieldName": "if_i_want_rename",
}],
fieldName is not required.
However to access your field value you will still have to use such SQL code:
SELECT
aAA.xxx.cell.value as xxx
FROM dev_test.telem_test

Amazon Product Advertising API v5 - How to retrieving different type of books (hardcopy, paperback, kindle... ) with one API call

I’m a developer for a company where we’re using Amazon's great product advertising API (PA-API) for a many years for fetching book information. We’re currently using the Java SDK and API v5.
Issue
We provide our customers directly links with our affiliate to the related hardcopy or ebook on different Amazon stores. We do this by creating a SearchItems documentation request with the ISBN (example 9780399562396) as the keyword and no specific search index. In the past we got a response back with two items and therefore two ASINs, one for the hardcopy and one for the ebook (distinguishable by the itemInfo’s product group). However, since some time we had to recognize that the response only contains normally one item, the hard copy product.
I have already tried different approaches with the great Scratchpad.
Questions
The interesting thing is that when I explicitly include the search index (more information here) “Books” or “KindleStore” the API is responding with the expected item (for "books" with a book and for "KindleStore" with a kindle). We do that by having a look at the ItemInfo.Classifications (more information here) However, if I search in the index “All” or don’t specified it, it returns only one item (normally the hardcopy). Which seems to me quite strange… Should the API/search index even behave like this?
Furthermore, I was not able to figure out how to search in to indexes within the same request and it seems to me that this is not supported at all but I would expect that at least this would then return two items…
Therefore, I would like ask you if somebody has an explanation for us to retrieve with one request both ASINs (kindle + hard copy book) of the same ISBN. Of course it is possible to create two separate requests for each product group, however since the API rates are tied to the shipped item revenue, we would like to avoid unnecessary API requests.
Some examples with and without the usage of the explicit usage of the search index
In the following example I looking for the hardcopy or kindle of the book with ISBN 9780262043649 by doing a SearchItem request.
a) Hardcopy with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "Books",
"PartnerTag": "*********",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "0262043645",
"DetailPageURL": "https://www.amazon.com/dp/0262043645?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Hardcover",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Book",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence (The MIT Press)",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=stripbooks&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
b) Kindle with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "KindleStore",
"PartnerTag": "******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=digital-text&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
c) No specific search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"PartnerTag": "*******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
Research/Further information
Documentation of the API
Search Index of Amazon
Scratchpad
Many thanks for any advice.

How to highlight custom extractions using a2i's crowd-textract-analyze-document?

I would like to create a human review loop for images that undergone OCR using Amazon Textract and Entity Extraction using Amazon Comprehend.
My process is:
send image to Textract to extract the text
send text to Comprehend to extract entities
find the Block IDs in Textract's output of the entities extracted by Comprehend
add new Blocks of type KEY_VALUE_SET to textract's JSON output per the docs
create a Human Task with crowd-textract-analyze-document element in the template and feed it the modified textract output
What fails to work in this process is step 5. My custom entities are not rendered properly. By "fails to work" I mean that the entities are not highlighted on the image when I click them on the sidebar. There is no error in the browser's console.
Has anyone tried such a thing?
Sorry for not including examples. I will remove secrets/PII from my files and attach them to the question
I used the AWS documentation of the a2i-crowd-textract-detection human task element to generate the value of the initialValue attribute. It appears the doc for that attribute is incorrect. While the the doc shows that the value should be in the same format as the output of Textract, namely:
[
{
"BlockType": "KEY_VALUE_SET",
"Confidence": 38.43309020996094,
"Geometry": { ... }
"Id": "8c97b240-0969-4678-834a-646c95da9cf4",
"Relationships": [
{ "Type": "CHILD", "Ids": [...]},
{ "Type": "VALUE", "Ids": [...]}
],
"EntityTypes": ["KEY"],
"Text": "Foo bar"
},
]
the a2i-crowd-textract-detection expects the input to have lowerCamelCase attribute names (rather than UpperCamelCase). For example:
[
{
"blockType": "KEY_VALUE_SET",
"confidence": 38.43309020996094,
"geometry": { ... }
"id": "8c97b240-0969-4678-834a-646c95da9cf4",
"relationships": [
{ "Type": "CHILD", "ids": [...]},
{ "Type": "VALUE", "ids": [...]}
],
"entityTypes": ["KEY"],
"text": "Foo bar"
},
]
I opened a support case about this documentation error to AWS.

Watson Assistant: Problem with extracting value for pattern entity

I am trying to get the value for the first group match of a pattern entity from the json response of Watson Assistant. The pattern is a simple regex to recognize sequences of numbers: ([0-9]+)
The json response looks like this:
"entity": "ID",
"location": [
18,
23
],
"value": "id",
"confidence": 1.0,
"groups": [
{
"group": "group_0",
"location": [
18,
23
]
}
]
},
{
"entity": "sys-number",
"location": [
18,
23
],
"value": "12345",
"confidence": 1.0,
"metadata": {
"numeric_value": 12345.0
}
}
]
So, the group is matched alright, but the field "value" is populated with the String literal from the entity config. I would expected to find the actual value there (which is the one the value field of the next entity, sys-number).
How do I need to change the config so that the value is included as-is in the value field (or somewhere else) and so that I don't have to extract the entity from the text string using the location values? Is it possible at all?
Thanks a lot
Cheers,
Martin
To access value of pattern based entity, you can either use <? #entity_name.literal ?> or <? #entity_name.groups[0] ?> - if there are more groups captured. You can find more info in the doc: https://cloud.ibm.com/docs/services/assistant?topic=assistant-entities

Where can I find documentation on the Nominatim geocoding response API?

I have begun using the Nominatim geocoding API. This page has reasonable documentation on the request parameters to the service. However, I can't find anywhere which details the response. Many of the response fields are obvious, but I would like to know more about osm_type, class, type and their possible values (and what they mean, of course). I would also like to understand what 'importance' refers to. I cannot find documentation on this output. Can anyone point me in the right direction?
Sample output:
[
{
"address": {
"city": "Berlin",
"city_district": "Mitte",
"construction": "Unter den Linden",
"continent": "European Union",
"country": "Deutschland",
"country_code": "de",
"house_number": "1",
"neighbourhood": "Scheunenviertel",
"postcode": "10117",
"public_building": "Kommandantenhaus",
"state": "Berlin",
"suburb": "Mitte"
},
"boundingbox": [
"52.5170783996582",
"52.5173187255859",
"13.3975105285645",
"13.3981599807739"
],
"class": "amenity",
"display_name": "Kommandantenhaus, 1, Unter den Linden, Scheunenviertel, Mitte, Berlin, 10117, Deutschland, European Union",
"importance": 0.73606775332943,
"lat": "52.51719785",
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
"lon": "13.3978352028938",
"osm_id": "15976890",
"osm_type": "way",
"place_id": "30848715",
"svg": "M 13.397511 -52.517283599999999 L 13.397829400000001 -52.517299800000004 13.398131599999999 -52.517315099999998 13.398159400000001 -52.517112099999999 13.3975388 -52.517080700000001 Z",
"type": "public_building"
}
]