Skip to content

Commit

Permalink
FIO-9086: use for validation only dataFormat (data storage format)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria.Golomb committed Sep 30, 2024
1 parent d651f03 commit d45b496
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/process/validation/rules/__tests__/validateTime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const timeField: TimeComponent = {
key: 'time',
label: 'Time',
input: true,
dataFormat: 'HH:mm:ss'
dataFormat: 'HH:mm:ss',
format: 'HH:mm'
};

it('Should validate a time component with a valid time value', async () => {
Expand Down
5 changes: 1 addition & 4 deletions src/process/validation/rules/validateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ export const validateTimeSync: RuleFnSync = (context: ValidationContext) => {
}
try {
if (!value || isComponentDataEmpty(component, data, path)) return null;
// Server side evaluations of validity should use the "dataFormat" vs the "format" which is used on the client.
const format = config?.server ?
((component as TimeComponent).dataFormat || 'HH:mm:ss') :
((component as TimeComponent).format || 'HH:mm');
const format = (component as TimeComponent).dataFormat || 'HH:mm:ss';
const isValid = dayjs(String(value), format, true).isValid();
return isValid ? null : new FieldError('time', context);
}
Expand Down

0 comments on commit d45b496

Please sign in to comment.