<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mauricio V on Medium]]></title>
        <description><![CDATA[Stories by Mauricio V on Medium]]></description>
        <link>https://medium.com/@vlltr?source=rss-11330142cb97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Uc5LV54AKUVUgDSECFChtw.jpeg</url>
            <title>Stories by Mauricio V on Medium</title>
            <link>https://medium.com/@vlltr?source=rss-11330142cb97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 18:39:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vlltr/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Block Temporary Emails and Aliases in Laravel — Without Dependencies]]></title>
            <link>https://vlltr.medium.com/block-temporary-emails-and-aliases-in-laravel-without-dependencies-2feb96afd7cd?source=rss-11330142cb97------2</link>
            <guid isPermaLink="false">https://medium.com/p/2feb96afd7cd</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Mauricio V]]></dc:creator>
            <pubDate>Mon, 26 May 2025 22:23:40 GMT</pubDate>
            <atom:updated>2025-05-26T22:23:40.860Z</atom:updated>
            <content:encoded><![CDATA[<h3>Block Temporary Emails and Aliases in Laravel — Without Dependencies</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*JB7P3sfPks2MsHmvl1QVRA.jpeg" /></figure><p>If you’re building a referral system in Laravel, there’s one thing you <em>must</em> secure early on:</p><p><strong>Stop users from signing up with temporary email addresses or email aliases.</strong></p><p>Otherwise, a single person can create 50 fake accounts using tricks like:</p><ul><li>abc@tempmail.com (temporary emails)</li><li>john+spam@gmail.com, jo.hn@gmail.com (aliases)</li></ul><p>In this post, you’ll learn how to block both <strong>without any external dependencies</strong>, using custom Laravel validation rules.</p><h3>Why This Matters</h3><p>Let’s say you reward users for inviting friends. Someone signs up, refers “friends” using:</p><ul><li>Fake disposable email accounts</li><li>email aliasing (which still routes to the same inbox)</li></ul><p>Boom. Free money, fake users, ruined data.</p><h3>The Fix: Reusable Laravel Rules</h3><p>Laravel makes it easy to encapsulate validation logic using custom Rule classes.</p><p>We’ll build two:</p><ol><li>NoTempEmail → blocks disposable/temporary domains</li><li>NoEmailAlias → blocks aliases (+)</li></ol><p>No external libraries, no API calls, no runtime dependencies.</p><h3>🔧 1. Block Temporary Email Domains</h3><h3>Create the rule</h3><pre>php artisan make:rule NoTempEmail</pre><h3>app/Rules/NoTempEmail.php</h3><pre>&lt;?php<br><br>namespace App\Rules;<br><br>use Closure;<br>use Illuminate\Contracts\Validation\ValidationRule;<br><br>class NoTempEmail implements ValidationRule<br>{<br>    protected array $blockProviders;<br>    // https://github.com/wesbos/burner-email-providers/blob/master/emails.txt<br>    public function __construct()<br>    {<br>        $this-&gt;blockProviders = [<br>            &#39;tempmail.com&#39;,<br>            &#39;10minutemail.com&#39;,<br>            &#39;mailinator.com&#39;,<br>            &#39;guerrillamail.com&#39;,<br>            &#39;yopmail.com&#39;,<br>            &#39;trashmail.com&#39;,<br>            &#39;maildrop.cc&#39;,<br>            &#39;fakeinbox.com&#39;,<br>            &#39;dispostable.com&#39;,<br>            &#39;getnada.com&#39;,<br>            //......<br>        ];<br>    }<br><br>    public function validate(string $attribute, mixed $value, Closure $fail): void<br>    {<br>        $value = strtolower($value);<br><br>        if(mb_strpos($value, &#39;@&#39;) === false) {<br>            $fail(&quot;The {$attribute} must be a valid email address.&quot;);<br>            return;<br>        }<br><br>        [$emailAccount, $emailProvider] = explode(&#39;@&#39;, $value);<br><br>        if(in_array($emailProvider, $this-&gt;blockProviders, true)) {<br>            $fail(&quot;The {$attribute} is not allowed.&quot;);<br>            return;<br>        }<br><br>    }<br>}</pre><h3>✂️ 2. Block Aliases</h3><ul><li>john.doe@gmail.com</li><li>johndoe@gmail.com</li><li>john+ref1@gmail.com</li></ul><p>…all at <strong>the same address</strong>. So users can cheat your referral system using aliasing.</p><h3>Create the rule</h3><pre>php artisan make:rule NoEmailAlias</pre><h3>app/Rules/NoEmailAlias.php</h3><pre>&lt;?php<br><br>namespace App\Rules;<br><br>use Closure;<br>use Illuminate\Contracts\Validation\ValidationRule;<br><br>class NoEmailAlias implements ValidationRule<br>{<br><br>    public function validate(string $attribute, mixed $value, Closure $fail): void<br>    {<br>        if (preg_match(&#39;/\+/&#39;, $value)) {<br>            $fail(&#39;The :attribute must not contain an email alias.&#39;);<br>            return;<br>        }<br><br>    }<br>}</pre><h3>📋 Use in a Form Request</h3><pre>use App\Rules\NoTempEmail;<br>use App\Rules\NoEmailAlias;<br><br>public function rules(): array<br>{<br>    return [<br>        &#39;email&#39; =&gt; [<br>            &#39;required&#39;,<br>            &#39;email&#39;,<br>            &#39;unique:users,email&#39;,<br>            new NoTempEmail,<br>            new NoEmailAlias,<br>        ],<br>    ];<br>}</pre><h3>Result</h3><ul><li>johndoe@gmail.com is <strong>accepted</strong></li><li>john+1@gmail.com is <strong>rejected</strong></li><li>abc@tempmail.org is <strong>rejected</strong></li></ul><p>You now protect your app from most fake signups using tricks like aliasing or disposable mail.</p><p>If this helped, give it a clap and share it with your team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2feb96afd7cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Laravel 12 Projects with Docker — No Local PHP Needed]]></title>
            <link>https://vlltr.medium.com/clean-laravel-12-projects-with-docker-no-local-php-needed-d7c09de9ae11?source=rss-11330142cb97------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7c09de9ae11</guid>
            <category><![CDATA[laravel-12]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Mauricio V]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 15:34:21 GMT</pubDate>
            <atom:updated>2025-04-19T15:37:44.694Z</atom:updated>
            <content:encoded><![CDATA[<h3>Clean Laravel 12 Projects with Docker — No Local PHP Needed</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sp0bhULlAL-dAqX87S4-NA.jpeg" /></figure><p>As a full-stack developer who relies on Docker for everything, I like keeping my local machine as clean as possible. I avoid installing PHP, Composer, or Node globally — because why pollute your system when you can run it all inside containers?</p><p>With Laravel 12, however, the “Laravel installer” experience isn’t as Docker-friendly out of the box. So I created a simple Bash script and alias that lets me spin up new Laravel 12 projects 100% Dockerized — with zero PHP on my host.</p><p>Here’s how it works 👇</p><h3>Step 1: Create a Laravel 12 Project (via Docker)</h3><p>We use the official Laravel Sail Composer image to scaffold a new project, completely inside a container:</p><pre>docker run -it --rm \<br>  --user &quot;$(id -u):$(id -g)&quot; \<br>  -v &quot;$(pwd):/app&quot; \<br>  -w /app \<br>  -e COMPOSER_HOME=/tmp/composer \<br>  laravelsail/php84-composer:latest \<br>  bash -c &quot;composer global require laravel/installer &amp;&amp; /tmp/composer/vendor/bin/laravel new your-project-name&quot;</pre><h3>Step 2: Install Sail (Still in Docker)</h3><p>Once the project is generated, we install Laravel Sail using the same containerized setup:</p><pre>docker run -it --rm \<br>  --user &quot;$(id -u):$(id -g)&quot; \<br>  -v &quot;$(pwd):/app&quot; \<br>  -w /app \<br>  -e COMPOSER_HOME=/tmp/composer \<br>  laravelsail/php84-composer:latest \<br>  php artisan sail:install</pre><h3>Automate It: Bash Script + Alias</h3><p>Here’s the full script I use (laravel-docker-new.sh):</p><pre>#!/bin/bash<br>if [ -z &quot;$1&quot; ]; then<br>    echo &quot;❌ You must provide a project name.&quot;<br>    echo &quot;👉 Usage: laravel-docker-new.sh my-project&quot;<br>    exit 1<br>fi<br>PROJECT_NAME=$1<br>docker run -it --rm \<br>  --user &quot;$(id -u):$(id -g)&quot; \<br>  -v &quot;$(pwd):/app&quot; \<br>  -w /app \<br>  -e COMPOSER_HOME=/tmp/composer \<br>  laravelsail/php84-composer:latest \<br>  bash -c &quot;composer global require laravel/installer &amp;&amp; /tmp/composer/vendor/bin/laravel new $PROJECT_NAME&quot;<br>cd &quot;$PROJECT_NAME&quot; || exit<br>docker run -it --rm \<br>  --user &quot;$(id -u):$(id -g)&quot; \<br>  -v &quot;$(pwd):/app&quot; \<br>  -w /app \<br>  -e COMPOSER_HOME=/tmp/composer \<br>  laravelsail/php84-composer:latest \<br>  php artisan sail:install<br>echo &quot;✅ Laravel project &#39;$PROJECT_NAME&#39; created.&quot;<br>echo &quot;👉 Next: cd $PROJECT_NAME &amp;&amp; ./vendor/bin/sail up&quot;</pre><p>Make it executable:</p><pre>chmod +x ~/bin/laravel-docker-new.sh</pre><p>Then add an alias to your ~/.zshrc or ~/.bashrc:</p><pre>alias sailnew=&quot;~/bin/laravel-docker-new.sh&quot;</pre><p>Reload your shell config:</p><pre>source ~/.zshrc  # or ~/.bashrc</pre><h3>Usage</h3><p>From now on, just run:</p><pre>sailnew blog-app</pre><p>And boom — you’ve got a fresh Laravel 12 project ready to go with Docker, no global PHP, and no mess.</p><h3>Why Bother?</h3><ul><li>No PHP/Composer/Node clutter on your host</li><li>Reproducible across teams</li><li>Works inside any Docker-compatible environment (WSL2, macOS, Linux, CI)</li></ul><p>This tiny script saves me time and keeps my setup ultra-clean. Hope it helps you too!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7c09de9ae11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creando reglas de validación personalizadas en Laravel]]></title>
            <link>https://vlltr.medium.com/creando-reglas-de-validaci%C3%B3n-personalizadas-en-laravel-79197ad63c?source=rss-11330142cb97------2</link>
            <guid isPermaLink="false">https://medium.com/p/79197ad63c</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Mauricio V]]></dc:creator>
            <pubDate>Fri, 18 Nov 2022 03:04:34 GMT</pubDate>
            <atom:updated>2023-05-20T22:15:35.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Laptop with code" src="https://cdn-images-1.medium.com/max/1024/0*6-56YlZyrI04dzfP" /><figcaption>Photo by <a href="https://unsplash.com/@afgprogrammer?utm_source=medium&amp;utm_medium=referral">Mohammad Rahmani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Muchas veces, cuando trabajamos con la entrada de información proporcionada por los usuarios, nos encontramos con la necesidad de crear reglas de validación precisas y específicas según nuestras necesidades.</p><p>Laravel ofrece reglas de validación muy útiles sin necesidad de implementar mucha lógica. Sin embargo, si necesitamos valores específicos como desarrolladores, debemos implementar soluciones para trabajar con estos datos. En este artículo, veremos cómo trabajar con las reglas de validación y cómo crear nuestras propias reglas personalizadas para implementarlas en nuestros proyectos.</p><p>En este artículo, simularemos un API donde podemos capturar los datos de un cliente. El caso de uso que abordaremos es el siguiente:</p><p>Durante muchos años, las personas naturales debían utilizar dos documentos: su DUI (Documento Único de Identidad) y el NIT (Número de Identificación Tributaria). Ambos documentos tienen un patrón diferente, siendo el NIT el de mayor longitud.</p><p>En la actualidad, ambos documentos están homologados y el DUI se utiliza también como documento tributario. Esto puede generar la situación en la que nuestro registro de documento tributario pueda tener dos patrones: el antiguo correspondiente al NIT, o el actual correspondiente al DUI.</p><p>¡Manos a la obra!</p><h3>Definiendo rutas</h3><p>Vamos a definir las siguientes rutas en nuestro archivo <strong>“routes/api.php”</strong>.</p><pre>&lt;?php<br><br>use Illuminate\Http\Request;<br>use Illuminate\Support\Facades\Route;<br><br>Route::post(&#39;customers&#39;, [App\Http\Controllers\CustomerController::class, &#39;store&#39;]);</pre><p>La ruta <strong>“POST” </strong>se encargara de guardar nuestros datos en la base de datos.</p><h3>Creando nuestro controlador</h3><p>Creamos nuestro controlador “<strong>CustomerController”</strong>.</p><pre>&lt;?php<br><br>namespace App\Http\Controllers;<br><br>use Illuminate\Http\Request;<br><br>class CustomerController extends Controller<br>{<br>    /**<br>     * Store Customer<br>     * <br>     * @param  \Illuminate\Http\Request  $request<br>     * @return \Illuminate\Http\Response<br>     **/<br>    public function store(Request $request)<br>    {<br>        //Validate and store data<br>    }<br>}</pre><h3>Creando la lógica de validación</h3><p>Una vez que hemos creado nuestra ruta y controlador, estamos listos para trabajar en la lógica de validación de datos.</p><p>Existen dos formas de realizar la validación: podemos crear un archivo dedicado para nuestras reglas, mensajes personalizados y autorizaciones (si son necesarias), o podemos hacerlo directamente en nuestro controlador.</p><p>La ventaja de trabajar con la primera opción es que podemos reutilizar nuestro formulario. Imaginemos que tenemos un API y una aplicación web, lo que implica tener dos controladores y dos rutas diferentes. Sin embargo, las validaciones siguen siendo las mismas. Si realizamos la validación directamente en nuestro controlador, cada vez que agreguemos más campos, tendremos que realizar modificaciones en todas las acciones del controlador. En cambio, al utilizar un archivo dedicado, podemos reutilizar esa validación.</p><p>Estos archivos dedicados se conocen como <a href="https://laravel.com/docs/master/validation#form-request-validation">Form Request</a>. Para crearlos, ejecutamos el siguiente comando en nuestra línea de comandos.</p><pre>php artisan make:request StoreCustomerRequest</pre><p>En nuestra carpeta <strong>App/Http/Request</strong> tendremos el siguiente archivo creado.</p><pre>&lt;?php<br><br>namespace App\Http\Requests;<br><br>use Illuminate\Foundation\Http\FormRequest;<br><br>class StoreCustomerRequest extends FormRequest<br>{<br>    /**<br>     * Determine if the user is authorized to make this request.<br>     *<br>     * @return bool<br>     */<br>    public function authorize()<br>    {<br>        return false;<br>    }<br><br>    /**<br>     * Get the validation rules that apply to the request.<br>     *<br>     * @return array&lt;string, mixed&gt;<br>     */<br>    public function rules()<br>    {<br>        return [<br>            //<br>        ];<br>    }<br>}</pre><p>Veamos, en nuestro archivo tenemos dos métodos: <strong>authorize </strong>y <strong>rules</strong>. En el primero, podremos tener un control de quién está autorizado para realizar esta petición. Aquí podemos agregar nuestra lógica de permisos de usuario, ya sea en este archivo o en otro lugar, como un servicio o en el controlador. En este caso, retornaremos un valor true para poder realizar nuestra petición.</p><p>Luego, tenemos el método rules, donde definiremos todas nuestras reglas para validar la información que recibimos. Laravel cuenta con una gran cantidad de reglas por defecto que puedes consultar en la <a href="https://laravel.com/docs/master/validation#available-validation-rules">documentación oficial</a>.</p><p>Ahora, para utilizar este<strong> Form Request</strong>, debemos inyectarlo en nuestro controlador de la siguiente manera:</p><pre>&lt;?php<br><br>namespace App\Http\Controllers;<br><br>use App\Http\Requests\StoreCustomerRequest;<br><br>class CustomerController extends Controller<br>{<br>    /**<br>     * Store Customer<br>     * <br>     * @param  \Illuminate\Http\Request  $request<br>     * @return \Illuminate\Http\Response<br>     **/<br>    public function store(StoreCustomerRequest $request)<br>    {<br>        //Validate and store data<br>    }<br>}</pre><h3>Creando nuestra matriz de validación</h3><p>Primero solo validaremos estos campos nombre, DUI y NIT, todos de carácter obligatorio y tanto el DUI (00000000–0) como el NIT (0000–000000–000–0)deben cumplir con un patrón.</p><p>Ahora nuestro <strong>StoreCustomerRequest</strong> queda de la siguiente forma.</p><pre>&lt;?php<br><br>namespace App\Http\Requests;<br><br>use Illuminate\Foundation\Http\FormRequest;<br><br>class StoreCustomerRequest extends FormRequest<br>{<br>    /**<br>     * Determine if the user is authorized to make this request.<br>     *<br>     * @return bool<br>     */<br>    public function authorize()<br>    {<br>        return true;<br>    }<br><br>    /**<br>     * Get the validation rules that apply to the request.<br>     *<br>     * @return array&lt;string, mixed&gt;<br>     */<br>    public function rules()<br>    {<br>        return [<br>            &#39;name&#39; =&gt; [&#39;required&#39;, &#39;string&#39;],<br>            &#39;dui&#39; =&gt; [&#39;required&#39;, &#39;regex:/^\d{8}-\d{1}$/&#39;],<br>            &#39;nit&#39; =&gt; [&#39;required&#39;],<br>        ];<br>    }<br>}</pre><p>Si nos fijamos, para validar nuestro DUI utilizamos una expresión regular (regex). Pero, ¿qué pasa con nuestro NIT? Podemos tener clientes cuyos NITs pueden tener dos longitudes diferentes, y debemos asegurarnos de que cumplan una de las dos condiciones. Podríamos utilizar <strong>preg_match </strong>y otra expresión regular, pero eso haría que nuestra validación no se vea tan limpia.</p><p>Para solucionar esto, crearemos nuestra propia “regla” de validación para el NIT.</p><h3>Creando nuestra regla personalizada</h3><p>Para crear nuestra regla debemos ejecutar lo siguiente en nuestra terminal.</p><pre>php artisan make:rule Document</pre><p>En nuestra carpeta <strong>App/Rules</strong> tendremos el siguiente archivo creado.</p><pre>&lt;?php<br><br>namespace App\Rules;<br><br>use Illuminate\Contracts\Validation\Rule;<br><br>class Document implements Rule<br>{<br>    /**<br>     * Create a new rule instance.<br>     *<br>     * @return void<br>     */<br>    public function __construct()<br>    {<br>        //<br>    }<br><br>    /**<br>     * Determine if the validation rule passes.<br>     *<br>     * @param  string  $attribute<br>     * @param  mixed  $value<br>     * @return bool<br>     */<br>    public function passes($attribute, $value)<br>    {<br>        //<br>    }<br><br>    /**<br>     * Get the validation error message.<br>     *<br>     * @return string<br>     */<br>    public function message()<br>    {<br>        return &#39;The validation error message.&#39;;<br>    }<br>}</pre><p>dentro de nuestra función agregamos nuestra lógica, quedando de la siguiente manera.</p><pre>&lt;?php<br><br>namespace App\Rules;<br><br>use Illuminate\Contracts\Validation\Rule;<br><br>class Document implements Rule<br>{<br>    /**<br>     * Determine if the validation rule passes.<br>     *<br>     * @param  string  $attribute<br>     * @param  mixed  $value<br>     * @return bool<br>     */<br>    public function passes($attribute, $value)<br>    {<br>        return preg_match(&#39;/^\d{8}-\d{1}$/&#39;, $value) || preg_match(&#39;/^\d{4}-\d{6}-\d{3}-\d{1}$/&#39;, $value);<br>    }<br><br>    /**<br>     * Get the validation error message.<br>     *<br>     * @return string<br>     */<br>    public function message()<br>    {<br>        return &#39;The :attribute format is invalid.&#39;;<br>    }<br>}</pre><p>Si intentamos enviar los datos y no cumplen con nuestra validación en nuestro API aparecerá así.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*Gz36Xz_t1XJRbDpqPPHxcg.png" /></figure><p>en caso que todas nuestra validaciones pasen podremos acceder a estos parámetros desde nuestra request de la siguiente forma.</p><pre>&lt;?php<br><br>namespace App\Http\Controllers;<br><br>use App\Http\Requests\StoreCustomerRequest;<br><br>class CustomerController extends Controller<br>{<br>    /**<br>     * Store Customer<br>     * <br>     * @param  \Illuminate\Http\Request  $request<br>     * @return \Illuminate\Http\Response<br>     **/<br>    public function store(StoreCustomerRequest $request)<br>    {<br>        //Validate and store data<br>        $validated = $request-&gt;safe();<br> <br>        $name = $validated[&#39;name&#39;];<br>        $dui = $validated[&#39;dui&#39;];<br>        $nit = $validated[&#39;nit&#39;];<br>    }<br>}</pre><p>Con eso, podemos guardar los datos en nuestra base de datos. Sin lugar a dudas, esta es una forma de trabajar con formularios dentro de Laravel, ya que nos brinda la flexibilidad de crear nuestras propias reglas y personalizar completamente el proceso de validación.</p><p>Si llegaste hasta aquí muchas gracias por leer este artículo y si te interesa revisar el código del proyecto completo te dejo el <a href="https://github.com/vlltr/validation-example">repositorio </a>de GitHub.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79197ad63c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>