ragflow/client/src/utils/rules.ts
2024-01-10 12:09:19 +08:00

12 lines
375 B
TypeScript

import { getMonospaceLength } from '@/utils/helper';
export const monospace = (rule, value, callback) => {
const length = getMonospaceLength(value);
if (rule.max > 0 && length > rule.max) {
callback(`长度不能超过${rule.max}!`);
} else if (rule.min > 0 && length < rule.min) {
callback(`长度不能小于${rule.min}!`);
} else {
callback();
}
};