Download the PHP package ms100/form-validation without Composer

On this page you can find all versions of the php package ms100/form-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package form-validation

表单验证类

  1. 安装 composer require ms100/form-validation,之后可参照 test 中的示例。
  2. 不会过滤没有设置验证规则的字段,所以一定不能直接将验证完的数据直接作为参数传给数据库函数或其他对数据格式有严格要求的方法中。
  3. 字段值不可以为 null,为 null 时候一定通不过验证。
  4. 如果数据为二维及以上数组,请定义好每一维的规则;只有父级存在并通过验证,子级的验证规则才会生效。

  5. 除了字符串格式,其他格式的字段要用 is_类型(包括 is_array, is_bool, is_string, is_numeric, is_int, is_float)函数修饰,例如某一个字段为数组格式,规则里一般要写上 is_array;如果字段值为字符串 is_string 可以不写,执行时会自动补全。

  6. 注意 表单字段不存在时,将只有 required, isset, matches, least_one_required, default_value 这几个规则生效;表单字段值为 空字符串、空数组时,将另有 not_empty_str, not_empty_array 这两个规则生效。

  7. 所有单个参数且返回值不为 bool 型的函数和方法(例如:trimarray_valuefilter_emoji)都会改变字段的值。
  8. reset_error 方法用来重置错误数据,可在批处理相同验证规则的数据时,不需要重复调用 set_rules 方法(若使用 reset_validation 方法重置验证类,则需要重复调用 set_rules)。
  9. 验证规则里的 field 字段,可以无限层级(虽然实际情况很少会用到):

    • name
    • basic[name]
    • work[]
    • work[][name]
    • basic[like][]
    • mm[nn][][ii]....
    • mm[nn][][ii][][jj]...
  10. feild 最后为 [] 的验证规则,会作用于没有被之前的同级规则匹配到的所有元素。所以 feild 最后为 [] 的验证规则一般要写在同级验证规则的最后。

CI原有规则

表单验证规则

修订和新增规则

规则名 用法举例 描述
required - 表示字段必须存在,且不可以为空字符串或空数组
isset - 表示字段必须存在,但可以为空字符串或空数组;isset 组合 上not_empty_str 相当于 required
not_empty_str - 表示字段可以不传,但不能为空字符。即:可以没有此字段,但不能传空字符,一般用于一个验证规则有多种提交情况的时候
not_empty_array - 表示字段可以不传,但不能为空数组。即:前端可以不传此字段,但不能传空数组,一般用于一个验证规则有多种提交情况的时候
filter_emoji - 可在表单验证时用来过滤表情符号;另表单验证时普通字符串数据酌情使用 trim 过滤前后空字符
default_value default[abc] 如果字段不存在或者值为空字符串的时候,给字段设置默认值
least_one_required least_one_required[其他字段名] 两个字段不可同时不传或为空
valid_card - 验证身份证号码,会实现校验逻辑
valid_phone_or_email - 验证字段值为手机号或邮箱其中一种
valid_phone - 验证手机号
valid_tel - 验证固定电话
valid_md5 - 验证md5后的字符串
max_length_gbk max_length_gbk[20] 验证字段长度不超过20,英文为一个字符,中文为两个
min_length_gbk min_length_gbk[30] 验证字段长度不小于30,英文为一个字符,中文为两个
date_later_than date_later_than[2018-02] 或 date_later_than[其他字段名] 验证日期必须晚于设置的日期或字段值
date_before_than date_before_than[2018-02] 或 date_later_than[其他字段名] 验证日期必须早于设置的日期或字段值
valid_date valid_date 或 valid_date[-1] 或 valid_date[1] 验证日期合法性,参数 -1 表示过去的时间,1 表示未来的时间,不传参数表示合法日期即可
count_min count_min[3] 表示数组元素数量不小于3个
count_max count_max[5] 表示数组元素数量不超过5个
count_exact count_exact[4] 表示数组元素数量为4个
valid_dfs_info_signature valid_dfs_info_signature 写在所有规则最后,验证CI\libraries\Signature::encode_dfs_info签名的字符串并解码返回原数据
valid_url_path_signature valid_url_path_signature 写在所有规则最后,验证CI\libraries\Signature::sign_url_path签名的字符串并解码返回原数据


All versions of form-validation with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
illuminate/translation Version ^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ms100/form-validation contains the following files

Loading the files please wait ....