Skip to content

Commit

Permalink
fix(kit): maskitoTimeOptionsGenerator was incorrectly limiting a si…
Browse files Browse the repository at this point in the history
…ngle digit value
  • Loading branch information
demensky committed Jul 22, 2024
1 parent 4a8ed57 commit 0e0637e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion projects/demo/src/pages/kit/time/time-mask-doc.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export default class TimeMaskDocComponent implements GeneratorOptions {

protected readonly timeSegmentMaxValuesOptions: Array<
Partial<MaskitoTimeSegments<number>>
> = [{hours: 23, minutes: 59, seconds: 59, milliseconds: 999}, {hours: 11}];
> = [
{hours: 23, minutes: 59, seconds: 59, milliseconds: 999},
{hours: 11},
{hours: 9, minutes: 9, seconds: 9, milliseconds: 9},
];

public mode: MaskitoTimeMode = this.modeOptions[0];
public timeSegmentMaxValues: Partial<MaskitoTimeSegments<number>> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import type {MaskitoPreprocessor} from '@maskito/core';
import {TIME_FIXED_CHARACTERS} from '../../../constants';
import type {MaskitoTimeMode, MaskitoTimeSegments} from '../../../types';
import {escapeRegExp} from '../../../utils';
import {padEndTimeSegments, validateTimeString} from '../../../utils/time';
import {padStartTimeSegments, validateTimeString} from '../../../utils/time';

export function createMaxValidationPreprocessor(
timeSegmentMaxValues: MaskitoTimeSegments<number>,
timeMode: MaskitoTimeMode,
): MaskitoPreprocessor {
const paddedMaxValues = padEndTimeSegments(timeSegmentMaxValues);
const paddedMaxValues = padStartTimeSegments(timeSegmentMaxValues);
const invalidCharsRegExp = new RegExp(
`[^\\d${TIME_FIXED_CHARACTERS.map(escapeRegExp).join('')}]+`,
);
Expand Down

0 comments on commit 0e0637e

Please sign in to comment.