guysartorelli/silverstripe-composable-validators
Composer 安装命令:
composer require guysartorelli/silverstripe-composable-validators
包简介
Adds composable form validators with reusable validation logic.
关键字:
README 文档
README
Thank you to Signify for making this module possible.
This module provides a number of reusable composable validators (including AJAX validation) for use both in the CMS and in frontend forms.
Make sure you check out the extensions documentation at a minimum - some of these should be applied in almost all projects using this module.
If your project has any automated client-side tests, or you are implementing a validator to be compatible with this module, please make sure you read the client side tests documentation.
Install
Install via composer:
composer require guysartorelli/silverstripe-composable-validators
Gotchas
Form submission with an AjaxCompositeValidator
The AjaxCompositeValidator adds a submit handler to your form. This doesn't always interact well with other submit handlers, and can result in either front-end validation being skipped or the form not submitting the way you expect it to, depending on which submit handler gets the event first. For best results, don't add additional submit handlers to the form.
If you're using the AjaxCompositeValidator on a form that uses undefinedoffset/silverstripe-nocaptcha, you should disable form submission handling for the NocaptchaField in that form (see instructions in the nocaptcha docs).
Available Validators
AjaxCompositeValidator
Subclass ofCompositeValidatorthat provides AJAX validation. Resolves an issue with losing data, faster turn-around for fixing validation problems, and provides a way to use the same validation for 'client-side' validation of frontend forms.WarningFieldsValidator
Displays a warning if some field(s) doesn't have a value. Useful for alerting users about data that is technically valid but may not provide the results they expectDependentRequiredFieldsValidator
UsesSearchFilters to define fields as required conditionally, based on the values of other fields (e.g. only required ifOtherFieldhas a value greater than 25).RequiredBlocksValidator
Require a specific elemental block(s) to exist in theElementalArea, with optional minimum and maximum numbers of blocks and optional positional validation.ConstraintsValidator
Validate values againstsymfony/validationconstraints. This is super powerful - definitely check it out.
Abstract Validators
BaseValidator
Includes methods useful for getting the actualFormFieldand its label.FieldHasValueValidator
Subclass ofBaseValidator. Useful for validators that require logic to check if a field has any value or not.
Traits
ValidatesMultipleFields
Useful for validators that can be fed an array of field names to be validated.ValidatesMultipleFieldsWithConfig
LikeValidatesMultipleFieldsbut requires a configuration array for each field to be validated.
guysartorelli/silverstripe-composable-validators 适用场景与选型建议
guysartorelli/silverstripe-composable-validators 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.64k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2023 年 07 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「validator」 「cms」 「validation」 「ajax」 「validators」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 guysartorelli/silverstripe-composable-validators 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 guysartorelli/silverstripe-composable-validators 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 guysartorelli/silverstripe-composable-validators 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Runn Me! Validation and Sanitization Library
Extension for Opis JSON Schema
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Supercharged text field validation.
统计信息
- 总下载量: 2.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2023-07-11