パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.0

the_validator

Flutter用のシンプルで使いやすい検証パッケージ。フォームフィールドや文字列、値の検証に使用できます。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
183
いいね数
25
Pub ポイント
130

パッケージをインストール

flutter pub add the_validator

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

バリデータは、シンプルで効率的なフォームフィールド、文字列、値の検証を目的とした軽量なFlutterパッケージです。メールアドレス、パスワード、カスタム条件などの入力を検証するための明確で直感的なAPIを提供します。複雑なセットアップなしに迅速に統合したい開発者に最適で、Android、iOS、Web、macOS、Windows、Linuxなど複数のプラットフォームをサポートしています。フォーム入力中にリアルタイムフィードバックを可能にするため、ユーザー体験を向上させます。最小限のアプローチにより、基本的または高度な検証ロジックが必要な任意のFlutterプロジェクトに簡単に導入できます。

用途

  • フォーム入力検証
  • メールアドレスとパスワードの確認
  • カスタム検証ルール
  • リアルタイムユーザーのフィードバック
  • ユーザー形式におけるデータ整合性
  • クロスプラットフォーム検証

主な機能

  • シンプルな API
  • 複数の検証タイプをサポートしています
  • リアルタイム検証
  • クロスプラットフォーム互換性
  • 拡張可能な検証ルール
  • 軽量で高速

適している対象

  • 初心者のFlutter開発者
  • 迅速な検証が必要なプロジェクト
  • モバイルおよびWebアプリケーション
  • フォーム中心のアプリ
  • 厳格なデータ入力要件を持つアプリ
  • 最小の依存関係を好む開発者

注意事項

  • 基本的な検証要件に限定される
  • 組み込みの国際化なし
  • 手動でのエラーメッセージ処理が必要です
  • 非常に複雑な検証ワークフローには適していない
  • 外部のGitHubリポジトリに依存しています
  • 基本的な例を超える最小限のドキュメント

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

The Validator

A simple & lightweight form and data validation package for flutter

How to use

The Validator can be used directly on a TextFormField validator parameter TextFormField(validator: FieldValidator.email())

The Validator can also be used as a stand alone validator Validatror.isPassword('SecretPass', shouldContainCapitalLetter: true)

Sample Usage (FieldValidator)

TextFormField( 
    controller: _emailController,
    validator: FieldValidator.email(),
    decoration: InputDecoration(labelText: "Email"),
    ),
                
 TextFormField( 
    controller: _passwordController,
        validator: FieldValidator.password(
        minLength: 8,
        shouldContainNumber: true,
        shouldContainCapitalLetter: true,
        shouldContainSmallLetter: true,
        shouldContainSpecialChars: true,
        errorMessage: "Password must match the required format",
        isNumberNotPresent: () { return "Password must contain number"; },
        isSpecialCharsNotPresent: () { return "Password must contain special characters"; },
        isCapitalLetterNotPresent: () { return "Password must contain capital letters"; }
        ),
        decoration: InputDecoration(labelText: "Email"),
    ),

To validate confirm password field

  // To validate confirm password field
  TextFormField(
      controller: _confirmPasswordController,
      obscureText: true,
      validator: FieldValidator.equalTo(_passwordController, message: "Password Mismatch"),
      decoration: InputDecoration(labelText: "Confirm Password"),
  )

Then make a call to formState .validate() to perform the validations on the textfields


RaisedButton(
  onPressed: () {
    // validate() inputed data
    if (_formKey.currentState.validate()) {

          _scaffoldKey.currentState
          .showSnackBar(SnackBar(content: Text("Yay! we got it right!")));
                      
    }
  },
  child: Text("Submit"),                  
)

Sample Usage 2 (Validator)

var password = 'Secret'
var confirmPassword = 'secret'
if (Validator.isPassword(password, shouldContainCapitalLetter: true)) {
  if (Validator.isEqualTo(password, confirmPassword)) {
    print("Go ahead & grant access")
  } else {
    print("Password mis match")
  }
}

Error messages

By default The Validator will give you a nice default error based on the the type of validation you specify for field or an input. But you can also override the default message

Default Error Messages

FieldValidator.alphaNumeric() will output Field must contain both alphabets and numbers

User Defined Error Message

FieldValidator.alphaNumeric(message: 'Your username must contain both numbers & alphabets')

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。