搜尋套件、儲存庫與 APP 分類

套件詳情v1.3.2

validatorless

此套件提供了一種在 Flutter 上驗證文字輸入的方式,靈感來自 Yup。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
8620
喜歡數
171
Pub 分數
150

安裝套件

flutter pub add validatorless

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Validatorless 是一個 Flutter 套件,旨在簡化文字輸入驗證,靈感來自 Yup。它提供了一種彈性且直覺的方式來定義表單欄位的驗證規則,讓開發者能以最少的樣板程式碼建立強大的輸入驗證邏輯。該套件支援多種驗證類型,並可輕鬆整合至跨多個平台的 Flutter 應用程式中。它著重於乾淨的語法與可擴展性,非常適合需要動態或複雜驗證工作流程的表單。

適用情境

  • 表單輸入驗證
  • 動態表單驗證
  • 自定驗證規則
  • 跨平台表單處理
  • 即時輸入反饋
  • 驗證錯誤訊息

主要特色

  • Yup 風格的語法
  • 可擴充的驗證規則
  • 最小化樣板程式碼
  • 支援非同步驗證
  • Platform-agnostic
  • 與 TextFormField 的輕鬆整合

適合對象

  • Flutter 開發人員建構表單
  • 需要即時驗證的應用程式
  • 使用 Yup 類驗證模式的團隊
  • 需要輕量級驗證的專案
  • 尋求簡單但強大的驗證的開發者

使用建議

  • 與完整框架相比,內建驗證器較少
  • 需要手動設定以處理複雜的驗證鏈
  • 無內建的本地化支援
  • 最適合簡單到中等複雜度的驗證需求

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Validatorless

Pub Version

This package provides a means to validate text inputs on the flutter and was inspired by Yup

Validatorless in pub.dev

how to use
dependencies:
  # Use the latest version available. Any is just a placeholder
  validatorless: any
TextFormField(
  decoration: InputDecoration(
    labelText: 'User e-mail',
  ),
  validator: Validatorless.multiple([
     Validatorless.email('The field must be an email'),
     Validatorless.required('The field is obligatory')
  ]),
)

or use

TextFormField(
  decoration: InputDecoration(
    labelText: 'CPF',
  ),
  validator: Validatorless.cpf('CPF not is valid'),
)
Validatorless options
  Validatorless.multiple(List<Validatorless>)
  Validatorless.required(String)
  Validatorless.email(String)
  Validatorless.min(int, String)
  Validatorless.max(int, String)
  Validatorless.between(int, int, String)
  Validatorless.number(String)
  Validatorless.cpf(String)
  Validatorless.cnpj(String)
  Validatorless.date(String)
  Validatorless.compare(TextEditingController, String)
  Validatorless.numbersBetweenInterval(Double, Double, String)
  Validatorless.onlyCharacters(String)
  Validatorless.regex(RegExp, String)
  Validatorless.length(int, String)
  Validatorless.phone(String) // (99) 99999-9999 or (99) 9999-9999
  Validatorless.cep(String)
  Validatorless.url(String)
  Validatorless.strongPassword(String, {int minLength})
  Validatorless.creditCard(String)
  Validatorless.placa(String)

Publishing

Pushes to master run .github/workflows/publish.yml: patch-bump pubspec.yaml (unless the push already changed the version), append CHANGELOG.md, commit with [skip ci], tag (1.3.1, no v prefix), create a GitHub Release, and dart pub publish --force.

Add a repository secret named PUB_CREDENTIALS_JSON (Settings → Secrets and variables → Actions) containing the full contents of the Dart credentials file after dart pub login:

  • Linux: ~/.pub-cache/credentials.json or ~/.config/dart/pub-credentials.json
  • macOS: ~/Library/Application Support/dart/pub-credentials.json

Do not commit that file. The workflow fails if the secret is missing.

所屬分類

原始碼儲存庫

使用此套件的專案