mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
@ -1,3 +1,5 @@
|
||||
import { match } from 'ts-pattern';
|
||||
|
||||
import { checkboxValidationSigns } from '@documenso/ui/primitives/document-flow/field-items-advanced-settings/constants';
|
||||
|
||||
import type { TCheckboxFieldMeta } from '../types/field-meta';
|
||||
@ -75,3 +77,15 @@ export const validateCheckboxField = (
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
export const validateCheckboxLength = (
|
||||
numberOfSelectedOptions: number,
|
||||
validationRule: '>=' | '=' | '<=',
|
||||
validationLength: number,
|
||||
) => {
|
||||
return match(validationRule)
|
||||
.with('>=', () => numberOfSelectedOptions >= validationLength)
|
||||
.with('=', () => numberOfSelectedOptions === validationLength)
|
||||
.with('<=', () => numberOfSelectedOptions <= validationLength)
|
||||
.exhaustive();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user