classes/Form.md

Form

Overview:

Form handles request-bound validation flows with deterministic output, CSRF checks, and old-input flashing.

Use Form when endpoints need one-shot parsing + validation + CSRF verification without repeating glue code between Request, Check, CSRF, and Session.

Public API:

submit options:

Return envelope:

Example:

$_REQUEST = ['email' => '  test@example.com  '];

$result = Form::submit([
  'email' => 'required|email',
], [
  'csrf' => false,
  'normalizers' => [
    'email' => function ($value) {
      return strtolower(trim((string) $value));
    },
  ],
]);

if (!$result['valid']) {
  var_dump(Form::errors());
}