Skip to content
Permalink
Browse files
fix(int-value): fix int-value validation (DEV-1277) (#815)
* fix(int-value): fix int-value validation

* chore(int-value): replace magic number with a more clear const
  • Loading branch information
mdelez committed Sep 6, 2022
1 parent 375166a commit d86dc7b61ac4cc70fb28393da65bbc8cc5480921
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
@@ -5,7 +5,7 @@
<ng-template #showForm>
<span [formGroup]="form">
<mat-form-field class="large-field child-value-component" floatLabel="never">
<input matInput [formControlName]="'value'" class="value" placeholder="Int value" type="number" [errorStateMatcher]="matcher">
<input matInput [formControlName]="'value'" class="value" placeholder="Int value" [errorStateMatcher]="matcher">
<mat-error *ngIf="valueFormControl.hasError('valueNotChanged') &&
(valueFormControl.touched || valueFormControl.dirty)">
<span class="custom-error-message">New value must be different than the current value.</span>
@@ -9,6 +9,8 @@ import { ValueErrorStateMatcher } from '../value-error-state-matcher';
// https://stackoverflow.com/questions/45661010/dynamic-nested-reactive-form-expressionchangedafterithasbeencheckederror
const resolvedPromise = Promise.resolve(null);

const DECIMAL_VALUE = 10;

@Component({
selector: 'app-int-value',
templateUrl: './int-value.component.html',
@@ -87,7 +89,7 @@ export class IntValueComponent extends BaseValueDirective implements OnInit, OnC

const newIntValue = new CreateIntValue();

newIntValue.int = this.valueFormControl.value;
newIntValue.int = parseInt(this.valueFormControl.value, DECIMAL_VALUE);

if (this.commentFormControl.value !== null && this.commentFormControl.value !== '') {
newIntValue.valueHasComment = this.commentFormControl.value;
@@ -105,7 +107,7 @@ export class IntValueComponent extends BaseValueDirective implements OnInit, OnC

updatedIntValue.id = this.displayValue.id;

updatedIntValue.int = this.valueFormControl.value;
updatedIntValue.int = parseInt(this.valueFormControl.value, DECIMAL_VALUE);

// add the submitted comment to updatedIntValue only if user has added a comment
if (this.commentFormControl.value !== null && this.commentFormControl.value !== '') {

0 comments on commit d86dc7b

Please sign in to comment.