mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-05-19 19:10:35 +03:00
27 lines
503 B
TypeScript
27 lines
503 B
TypeScript
import { ValidationResult } from './types';
|
|
|
|
export function validatePath(value: string): ValidationResult {
|
|
if (!value) {
|
|
return {
|
|
valid: false,
|
|
message: _('Path cannot be empty'),
|
|
};
|
|
}
|
|
|
|
const pathRegex = /^\/[a-zA-Z0-9_\-/.]+$/;
|
|
|
|
if (pathRegex.test(value)) {
|
|
return {
|
|
valid: true,
|
|
message: _('Valid'),
|
|
};
|
|
}
|
|
|
|
return {
|
|
valid: false,
|
|
message: _(
|
|
'Invalid path format. Path must start with "/" and contain valid characters',
|
|
),
|
|
};
|
|
}
|