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

パッケージ詳細v0.0.13

inspection

LaravelフレームワークのようにDartおよびFlutterでフォーム入力とデータを検証する

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

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

flutter pub add inspection

パッケージ概要

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

Inspection は、Laravel フレームワークを参考にしたフォーム入力とデータ検証を提供する Dart および Flutter パッケージです。開発者は宣言的に検証ルールを定義でき、複数のプラットフォーム間で堅牢かつ一貫したデータチェックを保証します。カスタムバリデーター、エラーメッセージ、チェーン可能なルールをサポートしており、Flutter アプリでのフォーム処理を簡素化します。このパッケージは Android、iOS、Web、macOS、Windows、Linux でスムーズに動作し、強力な検証ロジックを必要とするクロスプラットフォームアプリに最適です。

用途

  • Flutter アプリにおけるフォーム検証
  • 提出前のデータ整合性チェック
  • カスタム検証ルールの実装
  • クロスプラットフォーム検証の一貫性
  • リアルタイム入力フィードバック
  • APIリクエストデータの前処理

主な機能

  • Laravel風の検証構文
  • チェーン可能な検証ルール
  • カスタムバリデーターのサポート
  • ローカライズされたエラーメッセージ
  • 組み込みの一般的なバリデータ
  • プラットフォームに依存しない設計

適している対象

  • Laravel風の検証を求めるFlutter開発者
  • 複雑なフォームワークフローを持つアプリ
  • 一貫した検証パターンを必要とするチーム
  • 国際化が必要なプロジェクト
  • 再利用可能な検証ロジックを構築する開発者

注意事項

  • Laravelスタイルの検証概念の理解が必要です
  • 複雑なネストされた検証には追加の設定が必要になる場合があります
  • 熟達したパッケージと比べてドキュメントが限られている
  • 非常に高いパフォーマンスを要する検証ループには最適化されていない

元の README

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

Flutter Inspection Package

Pub License: MIT


Inspection

With Inspection you can validate your inputs in Flutter & Dart like Laravel Framework.

How to install :

Add this to your package's pubspec.yaml file:

dependencies:
  inspection: ^0.0.14

Then You can install packages from the command line:

$ pub get

or

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Now in your Dart code, you can use:

import 'package:inspection/inspection.dart';

Basic Usage :

You have a form , you want to validate inputs everyday in programming . With Inspection you can validate your inputs in Dart like Laravel Framework . See examples below .

You expect a required number with many conditions and rules : In this case , we get help from Inspection helper function .

  TextFormField(
    validator: (input) => inspection(input, 'required|numeric|between:2000,6000|contains:22,33,55|ends_with:0'),
  ),

You can use Inspection class :

  TextFormField(
    validator: (input) => Inspection().inspect(input, 'required|float'),
  ),

And you can use helper function and Inspection class with List of rules , so you can make a global validation configuration List and you can change your rules in whole of the application whenever you want.

  TextFormField(
    validator: (input) => inspection(input, ['required','float']),
  ),

or

TextFormField(
    validator: (input) => inspect(input, ['required','float']),
  ),

Options :

You can set attribute name , custom message and locale . For example :

TextFormField(
    validator: (input) => inspect(input, 'required|float',message: 'my custom message here !'),
  ),

Rules :

Rule Description Example
iran_national_code Input must be a iranian national code inspect(input,'iran_national_code')
have_alpha The attribute must have alpha in it inspect(input,'have_alpha')
alpha_num The attribute must contains only letters and numbers inspect(input,'alpha_num')
between The attribute must be between :min and :max inspect(input,'between:3,9')
contains The attribute must contains one of your worlds inspect(input,'contains:farid,farhad')
email The attribute must be a valid email inspect(input,'email')
ends_with The attribute must ends with your pattern inspect(input,'ends_with:bye')
gt The attribute must grater than :gt inspect(input,'gt:10')
gte The attribute must grater than or equal to :gte inspect(input,'gte:10')
hex The attribute must be a valid hex code inspect(input,'hex')
in The attribute must be one of options in your list inspect(input,'in:farid,farhad,john')
ip The attribute must be a valid IP inspect(input,'ip')
lt The attribute must be less than :lt inspect(input,'lt:100')
lte The attribute must be less than or equal to :lte inspect(input,'lte:100')
max The attribute must have maximum :max character inspect(input,'max:10')
min The attribute must have at least :min character inspect(input,'min:3')
not_in The attribute must not exists in list :not_in inspect(input,'not_in:saman,ahmad')
numeric The attribute must be a number inspect(input,'numeric')
alpha The attribute must contains only letters inspect(input,'alpha')
float The attribute must be float inspect(input,'float')
integer The attribute must be integer inspect(input,'integer')
number The attribute must contains only number inspect(input,'number')
regex The attribute must match with regex inspect(input,'regex:^[a-zA-Z0-9]')
required The attribute field is required inspect(input,'required')
starts_with The attribute must starts with your pattern inspect(input,'starts_with:hi')
url The attribute must be a valid url inspect(input,'url')

Locales :

Inspection supports two languages now . English with code : en , and Persian with code fa and Vietnamese with code vi. You can set locale when initialize inspection or in optional parameter of inspect method. For example :

  TextFormField(
    validator: (input) => Inspection(inspectionLocale : 'fa').inspect(input, 'required|in:farid,farhad'),
  ),

or

  TextFormField(
    validator: (input) => Inspection().inspect(input, 'required|in:farid,farhad',locale:'fa'),
  ),

Custom Rules :

You can simply extend from Inspection class and develop your custom rule . For example :

class CustomInspection extends Inspection {
  String myCustomRule(ruleString, inspectionCase) {
    switch (ruleString) {
      case 'myCustomRule':
        // Your conditional codes here or copy from a Rule class and change it to your own . 
        return MyCustomeRuleClass(inspectionCase).stringValidation();
    }
    return null;
  }
}

Contribute :

You can help me and contribute for :

  • New rules
  • More locales
  • Better exceptions

カテゴリー

ソースリポジトリ

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

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