<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Validation on seth-shi</title><link>https://sethix.com/tags/validation/</link><description>Recent content in Validation on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 01 Jun 2018 10:15:17 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/validation/index.xml" rel="self" type="application/rss+xml"/><item><title>Laravel Form size Validation for Numbers</title><link>https://sethix.com/posts/2018060110/</link><pubDate>Fri, 01 Jun 2018 10:15:17 +0800</pubDate><guid>https://sethix.com/posts/2018060110/</guid><description>To validate a numeric exact value, I referred to the form validation documentation:
size:value
The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to the integer value. For arrays, size corresponds to the count of the array. For files, size corresponds to the file size in kilobytes.
Original validation rule:
$data = [&amp;#39;age&amp;#39; =&amp;gt; 9]; $validator = \Illuminate\Support\Facades\Validator::make($data, [&amp;#39;age&amp;#39; =&amp;gt; &amp;#39;required|size:9&amp;#39;]); if ($validator-&amp;gt;fails()) { dd($validator-&amp;gt;errors()-&amp;gt;first()); } dd(&amp;#39;pass&amp;#39;); I expected it to validate numbers directly when the input 9 is an integer.</description></item></channel></rss>