Skip to content

Commit

Permalink
feat(cb2-8776): show error message not showing above field (#1089)
Browse files Browse the repository at this point in the history
* feat(cb2-8661): fix value type error

* feat(cb2-8776): move error logic to comonent from the html

feat(cb2-8776): added access descriptor

feat(cb2-8776): changed date logic to be greater than -1

feat(cb2-8776): added ternary to convertToNumber logic and removed unused variable

feat(cb2-8776): prevent submission when time is not provided

* feat(cb2-8776): removed console logs

* feat(cb2-8776): logic change

* feat(cb2-8776): remove console log
  • Loading branch information
Daniel-Searle authored Jul 31, 2023
1 parent a5eedf3 commit b528b28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/app/forms/components/date/date.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ export class DateComponent extends BaseControlComponent implements OnInit, OnDes
}
processDate(year: any, month: any, day: any, hour: any, minute: any, second: any) {
if (this.isoDate) {
if (year > 999 && month > -1 && day > -1 && hour > -1 && minute > -1) {
this.showError = true;
if (year > 999 && month > -1 && day > -1) {
if (hour > -1 && minute > -1) {
this.showError = true;
}
if (hour === 0 && minute === 0) {
this.showError = true;
}
}

return `${year || ''}-${this.padded(month)}-${this.padded(day)}T${this.padded(hour)}:${this.padded(minute)}:${this.padded(second)}.000`;
Expand Down
3 changes: 1 addition & 2 deletions src/app/forms/validators/date/date.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export class DateValidators {

private static validateTime(time: string, label: string | undefined) {
const [hours, minutes] = time.split(':');

if (!hours || !minutes) {
if (!hours || !minutes || (hours === '00' && minutes == '00')) {
return { invalidDate: { error: true, reason: `'${label || 'Date'}' must include time` } };
}
if (23 < Number.parseInt(hours, 10)) {
Expand Down

0 comments on commit b528b28

Please sign in to comment.