except method
Get all validated data except the specified fields.
Creates a new map containing all validated fields except those
specified in keys. This is the inverse of only.
Useful for excluding sensitive fields like passwords when logging or returning data, or for separating different types of data.
Example:
final formRequest = CreateUserRequest();
await formRequest.validate(request);
// Exclude sensitive data for logging
final safeData = formRequest.except(['password', 'token']);
logger.info('User created', safeData);
// Separate profile and auth data
final profileData = formRequest.except(['password', 'password_confirmation']);
final authData = formRequest.only(['email', 'password']);
Parameters:
keys: List of field names to exclude from the result
Returns: A new map containing all fields except the specified ones
Implementation
Map<String, dynamic> except(List<String> keys) {
if (_validatedData == null) return {};
final result = Map<String, dynamic>.from(_validatedData!);
for (final key in keys) {
result.remove(key);
}
return result;
}