mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-14 23:46:50 +03:00
21 lines
565 B
TypeScript
21 lines
565 B
TypeScript
import { ValidationResult } from './types';
|
|
|
|
// TODO refactor current validation and add tests
|
|
export function validateOutboundJson(value: string): ValidationResult {
|
|
try {
|
|
const parsed = JSON.parse(value);
|
|
|
|
if (!parsed.type || !parsed.server || !parsed.server_port) {
|
|
return {
|
|
valid: false,
|
|
message:
|
|
'Outbound JSON must contain at least "type", "server" and "server_port" fields',
|
|
};
|
|
}
|
|
|
|
return { valid: true, message: 'Valid' };
|
|
} catch {
|
|
return { valid: false, message: 'Invalid JSON format' };
|
|
}
|
|
}
|