Skip to content

Commit

Permalink
Enhances device form validation
Browse files Browse the repository at this point in the history
Adds number validation for 'y' and 'h' fields in the device edit form
Updates version to 0.37.37
  • Loading branch information
karol-preiskorn committed Nov 24, 2024
1 parent f55e018 commit dd72800
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3d-inventory-angular-ui",
"version": "0.37.36",
"version": "0.37.37",
"private": true,
"browser": {
"fs": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h3><i class="bi bi-hdd"></i> Edit Device</h3>
placeholder="h"
required
[ngClass]="{
'is-invalid': this.x?.status !== 'VALID',
'is-invalid': editDeviceForm.get('position')?.get('h')?.status !== 'VALID',
'is-valid': editDeviceForm.get('position')?.get('h')?.status === 'VALID',
}" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DeviceEditComponent implements OnInit {
// Arrow function for number validation
numberValidator: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
const value: number = control.value as number
if (Number.isNaN(value) || Number(value) < 0) {
if (Number.isNaN(value) || Number(value) > 100 || Number(value) < -100) {
return { invalidNumber: true }
}
return null
Expand All @@ -40,8 +40,8 @@ export class DeviceEditComponent implements OnInit {
modelId: ['', Validators.required],
position: this.formBulider.group({
x: [0, [Validators.required, this.numberValidator]],
y: [0, [Validators.required]],
h: [0, [Validators.required]],
y: [0, [Validators.required, this.numberValidator]],
h: [0, [Validators.required, this.numberValidator]],
}),
})
}
Expand Down

0 comments on commit dd72800

Please sign in to comment.