搜索插件、代码仓与 APP 分类

插件详情v1.3.2

validatorless

该包提供了一种在 Flutter 上验证文本输入的方法,灵感来自 Yup。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
8620
喜欢数
171
Pub 分数
150

安装插件

flutter pub add validatorless

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Validatorless 是一个 Flutter 包,旨在简化文本输入验证,灵感来自 Yup。它提供了一种灵活且直观的方式来定义表单字段的验证规则,使开发者能够以最少的样板代码创建强大的输入验证逻辑。该包支持多种验证类型,并可轻松集成到跨多个平台的 Flutter 应用程序中。它注重简洁的语法和可扩展性,非常适合需要动态或复杂验证流程的表单。

适合场景

  • 表单输入验证
  • 动态表单验证
  • 自定义验证规则
  • 跨平台表单处理
  • 实时输入反馈
  • 验证错误消息

主要特点

  • Yup 风格的语法
  • 可扩展的验证规则
  • 最小化样板代码
  • 支持异步验证
  • Platform-agnostic
  • 与 TextFormField 的轻松集成

适合对象

  • Flutter 开发人员构建表单
  • 需要实时验证的应用程序
  • 使用 Yup 类验证模式的团队
  • 需要轻量级验证的项目
  • 寻求简单而强大的验证的开发者

使用建议

  • 与完整框架相比,内置验证器有限
  • 需要手动设置以处理复杂的验证链
  • 无内置本地化支持
  • 最适合简单到中等复杂度的验证需求

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Validatorless

Pub Version

This package provides a means to validate text inputs on the flutter and was inspired by Yup

Validatorless in pub.dev

how to use
dependencies:
  # Use the latest version available. Any is just a placeholder
  validatorless: any
TextFormField(
  decoration: InputDecoration(
    labelText: 'User e-mail',
  ),
  validator: Validatorless.multiple([
     Validatorless.email('The field must be an email'),
     Validatorless.required('The field is obligatory')
  ]),
)

or use

TextFormField(
  decoration: InputDecoration(
    labelText: 'CPF',
  ),
  validator: Validatorless.cpf('CPF not is valid'),
)
Validatorless options
  Validatorless.multiple(List<Validatorless>)
  Validatorless.required(String)
  Validatorless.email(String)
  Validatorless.min(int, String)
  Validatorless.max(int, String)
  Validatorless.between(int, int, String)
  Validatorless.number(String)
  Validatorless.cpf(String)
  Validatorless.cnpj(String)
  Validatorless.date(String)
  Validatorless.compare(TextEditingController, String)
  Validatorless.numbersBetweenInterval(Double, Double, String)
  Validatorless.onlyCharacters(String)
  Validatorless.regex(RegExp, String)
  Validatorless.length(int, String)
  Validatorless.phone(String) // (99) 99999-9999 or (99) 9999-9999
  Validatorless.cep(String)
  Validatorless.url(String)
  Validatorless.strongPassword(String, {int minLength})
  Validatorless.creditCard(String)
  Validatorless.placa(String)

Publishing

Pushes to master run .github/workflows/publish.yml: patch-bump pubspec.yaml (unless the push already changed the version), append CHANGELOG.md, commit with [skip ci], tag (1.3.1, no v prefix), create a GitHub Release, and dart pub publish --force.

Add a repository secret named PUB_CREDENTIALS_JSON (Settings → Secrets and variables → Actions) containing the full contents of the Dart credentials file after dart pub login:

  • Linux: ~/.pub-cache/credentials.json or ~/.config/dart/pub-credentials.json
  • macOS: ~/Library/Application Support/dart/pub-credentials.json

Do not commit that file. The workflow fails if the secret is missing.

所属分类

源码仓库

使用此插件的项目