mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-14 23:46:50 +03:00
26 lines
487 B
TypeScript
26 lines
487 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',
|
|
};
|
|
}
|