Laravel 文本区域验证最佳实践

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48246933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:14:29  来源:igfitidea点击:

Laravel text area validation best practice

phplaravel

提问by Dmitry Malys

I am not sure what kind of validation I should use for comments in E-commerce website that I am currently developing. It is not much I want to validate but I'm worried about security.

我不确定我应该对我目前正在开发的电子商务网站中的评论使用哪种验证。我想验证的并不多,但我担心安全性。

So what is the best practice?

那么最佳实践是什么?

My code now looks like this:

我的代码现在看起来像这样:

$this->validate($request, [
    'comment' => 'max:1000',
]);

Is it safe to leave it like that?

就这样离开它安全吗?

回答by Mahdi Younesi

It depends on your needs but I could suggest some

这取决于您的需求,但我可以建议一些

$this->validate($request, [
    'comment' => 'required|min:3|max:1000',
]);