패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.0

the_validator

폼 필드 및 문자열과 값 검증에 사용할 수 있는 플러터를 위한 간단하고 쉬운 검증 패키지

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
183
좋아요
25
Pub 점수
130

패키지 설치

flutter pub add the_validator

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

검증기는 간단하고 효율적인 폼 필드, 문자열 및 값 검증을 위한 가벼운 Flutter 패키지입니다. 이메일, 비밀번호, 사용자 정의 조건과 같은 입력값을 검증하기 위해 깔끔하고 직관적인 API를 제공합니다. 복잡한 설정 없이 빠르게 통합하고 싶은 개발자에게 이상적이며, Android, iOS, Web, macOS, Windows, Linux 등 다양한 플랫폼을 지원합니다. 폼 입력 중 실시간 피드백을 가능하게 하여 사용자 경험을 향상시킵니다. 최소한의 접근 방식으로 기본 또는 고급 검증 로직이 필요한 모든 Flutter 프로젝트에 쉽게 도입할 수 있습니다.

사용 사례

  • 양식 입력 검증
  • 이메일 및 비밀번호 확인
  • 사용자 정의 검증 규칙
  • 실시간 사용자 피드백
  • 사용자 양식의 데이터 무결성
  • 크로스 플랫폼 검증

주요 기능

  • 간단한 API
  • 여러 검증 유형을 지원합니다
  • 실시간 검증
  • 크로스 플랫폼 호환성
  • 확장 가능한 검증 규칙
  • 경량이고 빠름

적합한 대상

  • 초보자 플러터 개발자
  • 빠른 검증이 필요한 프로젝트
  • 모바일 및 웹 애플리케이션
  • 폼 중심 앱
  • 엄격한 데이터 입력 요구 사항을 가진 앱
  • 최소 종속성을 선호하는 개발자

고려 사항

  • 기본 검증 요구 사항에 국한됨
  • 내장된 국제화 없음
  • 수동 오류 메시지 처리가 필요합니다
  • 매우 복잡한 검증 워크플로우에는 적합하지 않음
  • 외부 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')

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.