Skip to content

Document validation on SuperNative screens - #597

Open
wojt-janowski wants to merge 1 commit into
NativePHP:mainfrom
wojt-janowski:docs/validation
Open

wojt-janowski wants to merge 1 commit into
NativePHP:mainfrom
wojt-janowski:docs/validation

Conversation

@wojt-janowski

Copy link
Copy Markdown

Summary

Adds a Validation page to the Mobile v4 docs under Digging Deeper, between Data Binding and Reactivity. It documents the ValidatesInput trait from NativePHP/mobile-air#614, as Simon asked there.

It covers:

  • Adding the trait, with a complete screen and view example.
  • rules() or a $rules property, plus messages() and validationAttributes().
  • validate() vs validateOnly(), including using validateOnly() from an updated*() hook with .blur / .debounce, and the helpers addError(), resetValidation() and getErrorBag().
  • Showing errors with @error, and driving a text input's is-error / supporting from $errors.
  • Which handlers have their validation errors caught: view event handlers and native:model syncs are caught. Lifecycle hooks, #[On] / #[OnNative] listeners and #[Poll] methods still reach the error overlay. A callout covers the emit() case, where a parent's messages land in the child's bag.

It also notes that validateOnly() doesn't match wildcard rules yet, and that tests go through the same interaction path as a device.

The page is marked "since 4.7", the first mobile-air release with the trait.

Testing

  • php artisan test --filter=Documentation: 8 passed, including the check that every docs page renders.
  • Rendered the page locally and checked the sidebar entry, code blocks, @error examples and callouts.

Adds a Validation page under Mobile v4 Digging Deeper for the
ValidatesInput trait from NativePHP/mobile-air#614.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19b49-98cc-7647-bdf2-e7d59eff9d2f
Co-authored-by: Amp <amp@ampcode.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant