validate function

Map<String, String> validate(
  1. List<SchemaComponent> components,
  2. FormValues values, [
  3. FilamentStrings strings = const FilamentStrings()
])

Client-side validation hints — feedback only, never the last word.

The rules block on each component is a hint for immediate feedback; the server revalidates every submission and its 422 message is authoritative, arriving already translated in the panel's locale. So a rule here may only delay a submission a round-trip on an obvious typo — never forbid one the server would accept.

Pure and synchronous — no I/O, no BuildContext — so it is testable without a widget. Returns field name to message; empty when the form passes its client-side hints.

Implementation

Map<String, String> validate(
  List<SchemaComponent> components,
  FormValues values, [
  FilamentStrings strings = const FilamentStrings(),
]) {
  final errors = <String, String>{};
  for (final field in writableFields(components)) {
    final message = _validateField(field, values, strings);
    if (message != null) errors[field.name!] = message;

    if (field is RepeaterComponent) {
      errors.addAll(_validateRows(field, values, strings));
    }
  }
  return errors;
}