request validation utils

This commit is contained in:
Ankit Mahato
2025-11-17 06:25:32 +05:30
parent 6dfd8727e5
commit 68c8e9ed63
2 changed files with 19 additions and 0 deletions

View File

@@ -8,4 +8,5 @@ export 'http_utils.dart';
export 'js_utils.dart'; export 'js_utils.dart';
export 'save_utils.dart'; export 'save_utils.dart';
export 'ui_utils.dart'; export 'ui_utils.dart';
export 'validation_utils.dart';
export 'window_utils.dart'; export 'window_utils.dart';

View File

@@ -0,0 +1,18 @@
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;
}