summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-12-08 15:38:08 -0500
committerTucker Evans <tuckerevans24@gmail.com>2019-12-08 15:50:46 -0500
commit99287dff749f7c6fa050b597115270496738d77c (patch)
treeb6ecea8c5bddf26d2aaa44035aa5fc3ecf59a06a /recipeBuddy/src/app/add-recipe/add-recipe.component.ts
parent4efaeb517b94690483a14f25a224de73c0f1b055 (diff)
Add basic input validation to add recipe form
Validates: Name is required, Timer/Cook Time are digits, Amount/Servings are numbers (digits with optional decimal point).
Diffstat (limited to 'recipeBuddy/src/app/add-recipe/add-recipe.component.ts')
-rw-r--r--recipeBuddy/src/app/add-recipe/add-recipe.component.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
index b4f4d1e..50ea1cd 100644
--- a/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
+++ b/recipeBuddy/src/app/add-recipe/add-recipe.component.ts
@@ -26,7 +26,7 @@ export class AddRecipeComponent {
ingredients: this.fb.array([
this.fb.group({
ingrName: [''],
- amount: [''],
+ amount: ['', Validators.pattern('^[0-9]*(\.[0-9]*)?$')],
units: ['']
})
]),
@@ -36,8 +36,8 @@ export class AddRecipeComponent {
timer: ['']
})
]),
- servingSize: [''],
- cookTime: [''],
+ servingSize: ['', Validators.pattern('^[0-9]*(\.[0-9]*)?$')],
+ cookTime: ['', Validators.pattern('^[0-9]*$')],
tags: [''],
photos: ['']
});
@@ -57,7 +57,7 @@ export class AddRecipeComponent {
this.ingredients.push(
this.fb.group({
ingrName: [''],
- amount: [''],
+ amount: ['', Validators.pattern('^[0-9]*(\.[0-9]*)?$')],
units: ['']
})
);
@@ -75,7 +75,7 @@ export class AddRecipeComponent {
this.steps.push(
this.fb.group({
instruct: [''],
- timer: ['']
+ timer: ['', Validators.pattern('^[0-9]*$')]
})
);
}