My goal is to validate within the class definition and pass the errors to the UI.
Input Forms and Classes
My input form in HTML passes a String. My class expects a DateTime or int. I handle this by creating a public string variable and an internal variable (_variable) of the correct class. In the constructor, I parse the public string variable into the desired class.
I may try holding on to the public string in "quarantine" until the user submits the form and then set the internal variables. I am not sure if this is good practice.
I may try holding on to the public string in "quarantine" until the user submits the form and then set the internal variables. I am not sure if this is good practice.
Validation
First I need to be able to call the validation method from my polymer element. Dart.Polymer doesn't let me call the method directly with:<on-event = "{{instance.method}}">
So I create a method in my polymer element.
bool FormDateValidation ()=> instance.method();
Parse throws a FormatException. I want to catch and display the exception. The method becomes:
bool FormDateValidation (){
try{
return instance.method();
} catch(e){
formError = e;}
bool FormDateValidation ()=> instance.method();
Parse throws a FormatException. I want to catch and display the exception. The method becomes:
bool FormDateValidation (){
try{
return instance.method();
} catch(e){
formError = e;}
Questions:
- Can HTML pass DateTime and int directly?
- How to throw and catch an exception if the String Variable can not be parsed to the desired class?
No comments:
Post a Comment