mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-06-07 11:44:55 +03:00
feat: migrate validatePath to modular
This commit is contained in:
25
fe-app-podkop/src/validators/validatePath.ts
Normal file
25
fe-app-podkop/src/validators/validatePath.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user