- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在我的 symfony 项目中使用 MinLength 验证器。
下面是我的使用方法:
use Symfony\Component\Validator\Constraints\MinLength;
class RegisterNewUser
{
protected $password;
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
if( isset( $metadata->properties["password"] ) )
unset($metadata->properties["password"]);
$password_blank = new NotBlank();
$password_min = new MinLength(5);
$password_blank->message = "The password should not be blank";
$password_min->message = "The password is too short. It should have {{ limit }} characters or more";
$metadata->addPropertyConstraint('password', $password_blank);
$metadata->addPropertyConstraint('password', $password_min );
}
}
我收到的错误信息是:
FatalErrorException: Error: Class 'Symfony\Component\Validator\Constraints\MinLength' not found in...
最佳答案
我找到了解决方案:
来自 Symfony 文档:
The MinLength constraint is deprecated since version 2.1 and will be removed in Symfony 2.3. Use Length with the min option instead.
所以,解决方案是:
use Symfony\Component\Validator\Constraints\Length;
....
$password_min = new Length(array('min'=>5));
关于php - Symfony2 - MinLength 验证不起作用 - 未找到 MinLength,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16918175/
我正在尝试在我的 symfony 项目中使用 MinLength 验证器。 下面是我的使用方法: use Symfony\Component\Validator\Constraints\MinLeng
我正在尝试创建一个自动完成功能,由于结果集的大小,当输入的字符少于 3 个时不会触发搜索。然而,有些名字实际上只有 1 或 2 个字母。 解决方案是允许用户单击输入中的放大镜来提交,或“强制通过”具有
我正在使用 jquery 自动完成插件。配置为使用多个值。 我设置选项minLength:2 minLength 选项仅适用于第一个自动建议单词,对于多个值则不起作用。 我如何配置或需要重写哪种方法来
这是我在 stackoverflow 上发表的第一篇文章,该网站给我留下了深刻的印象! 我的问题是关于 jQuery 验证插件...特别是关于 minlength 方法。我有一组复选框,我想知道是否至
我将 minLength 设置为 3,以在输入至少 3 个字符时触发建议列表。 但是当输入 1 个字符时,下拉菜单会打开。如何让它工作? $('#remote .typeahead').typeahe
我是 knockout 的新手,正在尝试锻炼如何使用验证。我们有以下代码 - var MyObjectModel = function(myObject){ var self = th
我正在尝试创建一个密码文本字段,我希望用户输入至少 8 个字符。当设置了最大长度时,我真的很喜欢文本字段上可见的最大长度字符计数器的工作方式,我想知道是否有任何等效的最小长度。谢谢! 最佳答案 你必须
我已经使用远程数据源实现了 typeahead.js 和 bloodhound,它基本上按预期工作。但是,我已将 typeahead 上的 minLength 设置为 2,虽然我可以看到 ajax 请
为什么 minlenght 只能在 Chrome 中使用? Example on JSFIDDLE 最佳答案 根据this没有浏览器支持该功能。 尽管如此,我使用的是 Chrome 40
我有一个名为 Config 的常量,其中包含 task.minlength = 3 属性。 我将常量附加到 $rootScope 中: .run(function($rootScope, Config
我尝试仅在验证成功时提交表单。验证适用于 required 但不适用于 ng-minlength 表单输入无效,但表单仍在提交中。 Mobile
我在 http://jqueryui.com/demos/autocomplete/ 使用了“自定义数据和显示”示例并对其进行了一些简化,这样我就可以拥有值和 ID,如下所示: $(function(
如何在不影响其他元素的情况下为单个元素设置 minLength 编辑: 插件代码如下 (function ( $ ) { $.widget( "ui.combobox", {
我在手机输入中使用 $error.minlength,但是当我想验证此输入以启用按钮以向服务器发送表单时,$error.minlenght 值为空。在我输入内容之前它什么也没有显示,但是在我输入任何内
我正在尝试使用 ng-minlength 确保输入的最小长度,但它似乎在一种极端情况下失败了。它在添加或删除字符时正确验证,但如果删除整个输入,它将错误地返回到有效状态。这是一个已知缺陷,还是我错误地
我正在使用 jQuery 验证插件。 我想动态选择最小长度。 目前我正在尝试类似的方法,但它不起作用。 minlength:function () { if(val == 1 ) {
我有一个输入字段,用户可以通过它提交一些数据。 但是,如果数据字符长度小于10,那么他们将无法提交。 这意味着,如果用户尝试提交少于 10 个字符的数据,那么 google chrome 会显示此错
我需要将这两种模式组合在一起或在我的 中同时使用它们字段 我有模式匹配来检查有效时间 - 这很好用并且该字段是“不需要的”所以我们将接受一个空白字段 pattern="([01]?[0-9]|2[
我对 Node 还很陌生,所以可能是我没有正确使用 JSON Schema,如果我错了,请纠正我。 我一直在使用名为 jsonschema 的 npm 模块。 为了使用验证,我使用它如下: var V
似乎 minlength 的属性字段不起作用。 HTML5 中是否还有其他属性可以帮助我设置字段值的最小长度? 最佳答案 您可以使用 pattern attribute . required att
我是一名优秀的程序员,十分优秀!