Skip to content

Commit

Permalink
isPartialDay no longer returns false on empty value; type guards hand…
Browse files Browse the repository at this point in the history
…le undefined components
  • Loading branch information
brendanbond committed Sep 7, 2024
1 parent c2f3780 commit dfe6f35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const getDateValidationFormat = (component: DayComponent) => {

export const isPartialDay = (component: DayComponent, value: string | undefined) => {
if (!value) {
return false;
return true;
}
const [DAY, MONTH, YEAR] = component.dayFirst ? [0, 1, 2] : [1, 0, 2];
const values = value.split('/');
Expand Down
18 changes: 9 additions & 9 deletions src/utils/formUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,15 +1129,15 @@ export function findComponent(components: any, key: any, path: any, fn: any) {
});
}

const isCheckboxComponent = (component: Component): component is CheckboxComponent => component.type === 'checkbox';
const isDataGridComponent = (component: Component): component is DataGridComponent => component.type === 'datagrid';
const isEditGridComponent = (component: Component): component is EditGridComponent => component.type === 'editgrid';
const isDataTableComponent = (component: Component): component is DataTableComponent => component.type === 'datatable';
const hasChildComponents = (component: any): component is HasChildComponents => component.components != null;
const isDateTimeComponent = (component: Component): component is DateTimeComponent => component.type === 'datetime';
const isSelectBoxesComponent = (component: Component): component is SelectBoxesComponent => component.type === 'selectboxes';
const isTextAreaComponent = (component: Component): component is TextAreaComponent => component.type === 'textarea';
const isTextFieldComponent = (component: Component): component is TextFieldComponent => component.type === 'textfield';
const isCheckboxComponent = (component: any): component is CheckboxComponent => component?.type === 'checkbox';
const isDataGridComponent = (component: any): component is DataGridComponent => component?.type === 'datagrid';
const isEditGridComponent = (component: any): component is EditGridComponent => component?.type === 'editgrid';
const isDataTableComponent = (component: any): component is DataTableComponent => component?.type === 'datatable';
const hasChildComponents = (component: any): component is HasChildComponents => component?.components != null;
const isDateTimeComponent = (component: any): component is DateTimeComponent => component?.type === 'datetime';
const isSelectBoxesComponent = (component: any): component is SelectBoxesComponent => component?.type === 'selectboxes';
const isTextAreaComponent = (component: any): component is TextAreaComponent => component?.type === 'textarea';
const isTextFieldComponent = (component: any): component is TextFieldComponent => component?.type === 'textfield';

export function getEmptyValue(component: Component) {
switch (component.type) {
Expand Down

0 comments on commit dfe6f35

Please sign in to comment.