Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Using country and region in code and comment #2385

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ $.validator.addMethod( "giroaccountNL", function( value, element ) {

/**
* IBAN is the international bank account number.
* It has a country - specific format, that is checked here too
* It has a country/Region - specific format, that is checked here too
*
* Validation is case-insensitive. Please make sure to normalize input yourself.
*/
Expand Down Expand Up @@ -562,7 +562,7 @@ $.validator.addMethod( "iban", function( value, element ) {
return false;
}

// Check the country code and find the country specific format
// Check the country code and find the country/region specific format
countrycode = iban.substring( 0, 2 );
bbancountrypatterns = {
"AL": "\\d{8}[\\dA-Z]{16}",
Expand Down Expand Up @@ -633,17 +633,17 @@ $.validator.addMethod( "iban", function( value, element ) {

bbanpattern = bbancountrypatterns[ countrycode ];

// As new countries will start using IBAN in the
// As new countries or regions will start using IBAN in the
// future, we only check if the countrycode is known.
// This prevents false negatives, while almost all
// false positives introduced by this, will be caught
// by the checksum validation below anyway.
// Strict checking should return FALSE for unknown
// countries.
// countries or regions.
if ( typeof bbanpattern !== "undefined" ) {
ibanregexp = new RegExp( "^[A-Z]{2}\\d{2}" + bbanpattern + "$", "" );
if ( !( ibanregexp.test( iban ) ) ) {
return false; // Invalid country specific format
return false; // Invalid country/region specific format
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ $.validator.addMethod("giroaccountNL", function(value, element) {

/**
* IBAN is the international bank account number.
* It has a country - specific format, that is checked here too
* It has a country/Region - specific format, that is checked here too
*/
$.validator.addMethod("iban", function(value, element) {
// some quick simple tests to prevent needless work
Expand All @@ -437,7 +437,7 @@ $.validator.addMethod("iban", function(value, element) {
cOperator = "",
countrycode, ibancheck, charAt, cChar, bbanpattern, bbancountrypatterns, ibanregexp, i, p;

// check the country code and find the country specific format
// check the country code and find the country/region specific format
countrycode = iban.substring(0, 2);
bbancountrypatterns = {
"AL": "\\d{8}[\\dA-Z]{16}",
Expand Down Expand Up @@ -507,17 +507,17 @@ $.validator.addMethod("iban", function(value, element) {
};

bbanpattern = bbancountrypatterns[countrycode];
// As new countries will start using IBAN in the
// As new countries or regions will start using IBAN in the
// future, we only check if the countrycode is known.
// This prevents false negatives, while almost all
// false positives introduced by this, will be caught
// by the checksum validation below anyway.
// Strict checking should return FALSE for unknown
// countries.
// countries or regions.
if (typeof bbanpattern !== "undefined") {
ibanregexp = new RegExp("^[A-Z]{2}\\d{2}" + bbanpattern + "$", "");
if (!(ibanregexp.test(iban))) {
return false; // invalid country specific format
return false; // invalid country/region specific format
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ protected async Task<DialogTurnResult> SetMarket(WaterfallStepContext sc, Cancel

if (string.IsNullOrWhiteSpace(userState.Market))
{
string country = (string)sc.Result;
string countryregion = (string)sc.Result;

// use AzureMaps API to get country code from country input by user
userState.Market = await _mapsService.GetCountryCodeAsync(country);
// use AzureMaps API to get country code from country or region input by user
userState.Market = await _mapsService.GetCountryCodeAsync(countryregion);
}

return await sc.NextAsync();
}

protected async Task<bool> MarketPromptValidatorAsync(PromptValidatorContext<string> promptContext, CancellationToken cancellationToken)
{
var country = promptContext.Recognized.Value;
var countryregion = promptContext.Recognized.Value;

// check for valid country code
country = await _mapsService.GetCountryCodeAsync(country);
if (country != null)
var countryCode = await _mapsService.GetCountryCodeAsync(countryregion);
if (countryCode != null)
{
return await Task.FromResult(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace NewsSkill.Models
public class SearchAddress
{
/// <summary>
/// Gets or sets a string specifying the country of an address.
/// Gets or sets a string specifying the country or region name of an address.
/// </summary>
/// <value>
/// A string specifying the country of an address.
/// A string specifying the country or region name of an address.
/// </value>
[JsonProperty(PropertyName = "countryCode")]
public string CountryCode { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class FindArticlesResponses : TemplateManager
["default"] = new TemplateIdMap
{
{ TopicPrompt, (context, data) => "What topic are you interested in?" },
{ MarketPrompt, (context, data) => "What country do you want to search in?" },
{ MarketPrompt, (context, data) => "What country or region do you want to search in?" },
{ ShowArticles, (context, data) => ShowArticleCards(context, data) }
},
["en"] = new TemplateIdMap { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class MainResponses : TemplateManager
{ Greeting, (context, data) => MainStrings.GREETING },
{ Help, (context, data) => SendHelpCard(context, data) },
{ Intro, (context, data) => SendIntroCard(context, data) },
{ MarketPrompt, (context, data) => "What country do you want to search in?" },
{ MarketRetryPrompt, (context, data) => "Couldn't find that country. What country do you want to search in?" }
{ MarketPrompt, (context, data) => "What country or region do you want to search in?" },
{ MarketRetryPrompt, (context, data) => "Couldn't find that country or region. What country or region do you want to search in?" }
},
["en"] = new TemplateIdMap { },
["fr"] = new TemplateIdMap { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TrendingArticlesResponses : TemplateManager
{
["default"] = new TemplateIdMap
{
{ MarketPrompt, (context, data) => "What country are you in?" },
{ MarketPrompt, (context, data) => "What country or region are you in?" },
{ ShowArticles, (context, data) => ShowArticleCards(context, data) }
},
["en"] = new TemplateIdMap { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public class Address

/// <summary>
/// Gets or sets a string specifying the populated place for the address.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries or regions.
/// </summary>
/// <value>
/// A string specifying the populated place for the address.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries or regions.
/// </value>
[JsonProperty(PropertyName = "locality")]
public string Locality { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public class SearchAddress

/// <summary>
/// Gets or sets a string specifying the populated place for the address.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries or regions.
/// </summary>
/// <value>
/// A string specifying the populated place for the address.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries.
/// This typically refers to a city, but may refer to a suburb or a neighborhood in certain countries or regions.
/// </value>
[JsonProperty(PropertyName = "municipalitySubdivision")]
public string MunicipalitySubdivision { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Location
public string State { get; set; }

[JsonProperty(PropertyName = "country")]
public string Country { get; set; }
public string CountryRegion { get; set; }

[JsonProperty(PropertyName = "formattedAddress")]
public string[] FormattedAddress { get; set; }
Expand Down