json static method
Validates that a string contains only valid JSON.
Implementation
static String? json(String? value, {String? message}) {
if (value == null || value.isEmpty) {
return null;
}
try {
// Try to parse as JSON
// ignore: unused_local_variable
final _ = Uri.decodeComponent(value);
return null;
} catch (e) {
return message ?? 'Please enter valid JSON.';
}
}