diff --git a/source/dotnet/Library/AdaptiveCards.Templating/AdaptiveCardTemplate.cs b/source/dotnet/Library/AdaptiveCards.Templating/AdaptiveCardTemplate.cs
index 75e9309350..167bd67dc0 100644
--- a/source/dotnet/Library/AdaptiveCards.Templating/AdaptiveCardTemplate.cs
+++ b/source/dotnet/Library/AdaptiveCards.Templating/AdaptiveCardTemplate.cs
@@ -71,7 +71,39 @@ internal static string ConvertToJson(object obj)
///
/// string in json or seriazable object
public AdaptiveCardTemplate(string jsonTemplate)
+ : this(jsonTemplate, validate: false) { }
+
+ ///
+ /// Creates an instance of AdaptiveCardTemplate
+ ///
+ ///
+ /// Once created, it will contain a parsed tree based on jsonTemplate
+ /// Data is bound by calling Expand on the object
+ /// The intance can be rebound with different data by calling Expand
+ ///
+ ///
+ ///
+ ///
+ /// var jsonTemplate = "
+ /// {
+ /// "type": "AdaptiveCard",
+ /// "version": "1.0",
+ /// "body": [
+ /// {
+ /// "type": "TextBlock",
+ /// "text": "Hello ${person.firstName}"
+ /// }
+ /// ]
+ ///}"
+ /// var template = new AdaptiveCardTemplate(jsonTemplate);
+ ///
+ ///
+ /// string in json or seriazable object
+ public AdaptiveCardTemplate(string jsonTemplate, bool validate)
{
+ if (validate && string.IsNullOrWhiteSpace(jsonTemplate))
+ throw new ArgumentException("The value cannot be an empty string or composed entirely of whitespace.", nameof(jsonTemplate));
+
if (jsonTemplate != null)
{
jsonTemplateString = jsonTemplate;
@@ -84,6 +116,11 @@ public AdaptiveCardTemplate(string jsonTemplate)
BuildParseTree = true
};
+ if (validate)
+ {
+ parser.ErrorHandler = new BailErrorStrategy();
+ }
+
parseTree = parser.json();
}
}