Inspection은 Laravel 프레임워크를 영감으로 삼아 폼 입력 및 데이터 검증을 제공하는 Dart와 Flutter 패키지입니다. 개발자는 유효성 검사 규칙을 선언적으로 정의할 수 있어 다양한 플랫폼에서 강력하고 일관된 데이터 검사를 보장합니다. 사용자 정의 검증기, 오류 메시지, 체이닝 가능한 규칙을 지원하여 Flutter 앱에서 폼 처리를 간소화합니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux에서 원활하게 작동하므로 강력한 검증 로직이 필요한 크로스플랫폼 애플리케이션에 이상적입니다.
사용 사례
Flutter 앱에서의 폼 검증
제출 전 데이터 무결성 검사
사용자 정의 검증 규칙 구현
크로스 플랫폼 검증 일관성
실시간 입력 피드백
API 요청 데이터 전처리
주요 기능
Laravel와 유사한 검증 구문
체인 가능한 검증 규칙
사용자 정의 검증기 지원
로컬라이즈된 오류 메시지
내장된 일반 검증기
플랫폼 독립적 설계
적합한 대상
Laravel 스타일 검증을 찾는 Flutter 개발자
복잡한 양식 워크플로를 가진 앱
일관된 검증 패턴이 필요한 팀
국제화가 필요한 프로젝트
재사용 가능한 검증 로직을 구축하는 개발자
고려 사항
Laravel 스타일의 검증 개념에 대한 이해가 필요합니다
복잡한 중첩 검증을 위해 추가 설정이 필요할 수 있습니다
성숙한 패키지에 비해 문서가 제한적
극도로 높은 성능 검증 루프에 최적화되지 않음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
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;
}
}