Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added adaptivecards-fabric #3106

Merged
merged 7 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
CR feedback. updated string parsing; updated number parsing
  • Loading branch information
Denis Fisenko committed Jun 25, 2019
commit 41335be07fa52ccc956987521ebe67b4a9ed2ca5
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class InputNumberFabric extends Shared.ReactInputElement {
public parse = (json: any, errors?: AC.IValidationError[]) => {
this.value = json.value;
this.id = AC.getStringValue(json.id);
this.min = json.min ? parseInt(AC.getStringValue(json.min), 10) : undefined;
this.max = json.max ? parseInt(AC.getStringValue(json.max), 10) : undefined;
this.min = Shared.getIntValue(json.min);
this.max = Shared.getIntValue(json.max);
this.placeholder = AC.getStringValue(json.placeholder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class InputTextFabric extends Shared.ReactInputElement {
this.value = json.value;
this.id = AC.getStringValue(json.id);
this.isMultiline = AC.getBoolValue(json.isMultiline, false);
this.maxLength = json.maxLength ? parseInt(AC.getStringValue(json.maxLength), 10) : undefined;
this.maxLength = Shared.getIntValue(json.maxLength);
this.placeholder = AC.getStringValue(json.placeholder);
this.label = AC.getStringValue(json.label);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class InputTimeFabric extends Shared.ReactInputElement {
this.id = AC.getStringValue(json.id);
this.value = json.value;
this.placeholder = AC.getStringValue(json.placeholder);
this.min = json.min ? AC.getStringValue(json.min) : undefined;
this.max = json.max ? AC.getStringValue(json.max) : undefined;
this.min = AC.getStringValue(json.min);
this.max = AC.getStringValue(json.max);
}

protected renderReact = (): JSX.Element => {
Expand Down
10 changes: 10 additions & 0 deletions source/nodejs/adaptivecards-fabric/src/Utils/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,13 @@ export const raiseParseError = (error: AC.IValidationError, errors: Array<AC.IVa
}
};

export const getIntValue = (val: any, errors?: AC.IValidationError[], defaultValue: number = undefined): number => {
try {
return val ? parseInt(val, 10) : defaultValue;
} catch (error) {
raiseParseError({
error: AC.ValidationError.InvalidPropertyValue,
message: error,
}, errors);
}
};