( adapter: DateAdapter<unknown> | null, formats: MatDateFormats | null, )
| 108 | |
| 109 | /** Checks whether a date adapter is set up correctly for use with the timepicker. */ |
| 110 | export function validateAdapter( |
| 111 | adapter: DateAdapter<unknown> | null, |
| 112 | formats: MatDateFormats | null, |
| 113 | ) { |
| 114 | function missingAdapterError(provider: string) { |
| 115 | return Error( |
| 116 | `MatTimepicker: No provider found for ${provider}. You must add one of the following ` + |
| 117 | `to your app config: provideNativeDateAdapter, provideDateFnsAdapter, ` + |
| 118 | `provideLuxonDateAdapter, provideMomentDateAdapter, or provide a custom implementation.`, |
| 119 | ); |
| 120 | } |
| 121 | |
| 122 | if (!adapter) { |
| 123 | throw missingAdapterError('DateAdapter'); |
| 124 | } |
| 125 | |
| 126 | if (!formats) { |
| 127 | throw missingAdapterError('MAT_DATE_FORMATS'); |
| 128 | } |
| 129 | |
| 130 | if ( |
| 131 | formats.display.timeInput === undefined || |
| 132 | formats.display.timeOptionLabel === undefined || |
| 133 | formats.parse.timeInput === undefined |
| 134 | ) { |
| 135 | throw new Error( |
| 136 | 'MatTimepicker: Incomplete `MAT_DATE_FORMATS` has been provided. ' + |
| 137 | '`MAT_DATE_FORMATS` must provide `display.timeInput`, `display.timeOptionLabel` ' + |
| 138 | 'and `parse.timeInput` formats in order to be compatible with MatTimepicker.', |
| 139 | ); |
| 140 | } |
| 141 | } |
no test coverage detected