validate method
Validates data against the form definition.
Performs comprehensive validation of input data based on the validators defined in the collection's form. This method can validate all fields or only specific fields if specified.
Parameters:
data
- The data to validate as a map of field names to valuesonlyCheckKeys
- Optional list of specific field names to validate. If empty, all fields in the data will be validated.
Returns a FormResultFree containing validation results and processed data.
Example:
var result = await collection.validate({
'name': 'John Doe',
'email': 'john@example.com',
});
if (result.success) {
print('Data is valid');
} else {
print('Validation errors: ${result.errors}');
}
Implementation
Future<FormResultFree> validate(
Map<String, Object?> data, {
List<String> onlyCheckKeys = const [],
}) async {
return form.validate(
data,
onlyCheckKeys: onlyCheckKeys,
);
}