Files
apidash/lib/utils/validation_utils.dart
2025-11-17 06:25:32 +05:30

19 lines
561 B
Dart

import 'package:apidash_core/apidash_core.dart';
String? getValidationResult(HttpRequestModel requestModel) {
if (requestModel.url.trim().isEmpty) {
return 'Request URL is empty. Please provide a valid URL.';
}
if (requestModel.method == HTTPVerb.get && requestModel.hasAnyBody) {
return 'GET request contains a body. This is not supported.';
}
if (requestModel.hasJsonData) {
try {
kJsonDecoder.convert(requestModel.body!);
} catch (e) {
return 'Invalid JSON in request body: ${e.toString()}';
}
}
return null;
}