Aus öffentlichen Paketdaten erstellte Orientierung.
Inspection ist ein Dart- und Flutter-Paket, das Formular-Eingaben und Datenvalidierung bietet, inspiriert durch den Laravel-Framework. Es ermöglicht Entwicklern, Validierungsregeln deklarativ zu definieren, wodurch robuste und konsistente Datenschecks über verschiedene Plattformen hinweg gewährleistet werden. Mit Unterstützung für benutzerdefinierte Validatoren, Fehlermeldungen und verkettbare Regeln vereinfacht es die Formulareverarbeitung in Flutter-Apps. Das Paket funktioniert nahtlos auf Android, iOS, Web, macOS, Windows und Linux und ist daher ideal für plattformübergreifende Anwendungen mit starker Validierungslogik.
Anwendungsfälle
Formularvalidierung in Flutter-Apps
Datenintegritätsprüfungen vor der Übermittlung
Implementierung einer benutzerdefinierten Validierungsregel
Plattformübergreifende Validierungs-Konsistenz
Eingabeparameter in Echtzeit
Datenpräprozessierung bei API-Anfragen
Hauptmerkmale
Laravel-ähnliche Validierungssyntax
Kettenfähige Überprüfungsregeln
Benutzerdefinierte Validatoren-Unterstützung
lokalisierter Fehlermeldungen
Eingebaute allgemeine Validatoren
Plattformunabhängiger Entwurf
Geeignet für
Flutter-Entwickler, die Validierung im Stil von Laravel suchen
Apps mit komplexen Formularworkflows
Teams, die konsistente Validierungsmuster benötigen
Projekte, die Internationalisierung erfordern
Entwickler, die wiederverwendbare Überprüfungslogik erstellen
Hinweise
Erfahrung mit Laravel-artigen Validierungskonzepten erforderlich
Kann zusätzliche Einstellungen für komplexe verschachtelte Validierungen erfordern
Geringe Dokumentation im Vergleich zu reifen Paketen
Nicht für extrem leistungsstarke Validierungs-Schleifen optimiert
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
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:
$pubget
or
$flutterpubget
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 .
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.
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 :
You can simply extend from Inspection class and develop your custom rule . For example :
classCustomInspectionextendsInspection{
StringmyCustomRule(ruleString, inspectionCase) {
switch (ruleString) {
case'myCustomRule':
// Your conditional codes here or copy from a Rule class and change it to your own . returnMyCustomeRuleClass(inspectionCase).stringValidation();
}
returnnull;
}
}