<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Taisei</title>
    <description>The latest articles on Forem by Taisei (@taiseidev26).</description>
    <link>https://forem.com/taiseidev26</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3455391%2F0ed438b4-3fca-46fa-93c0-dd9402a75712.jpeg</url>
      <title>Forem: Taisei</title>
      <link>https://forem.com/taiseidev26</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/taiseidev26"/>
    <language>en</language>
    <item>
      <title>How to Remove a Specific Error with Angular's setErrors()</title>
      <dc:creator>Taisei</dc:creator>
      <pubDate>Sat, 06 Sep 2025 12:56:02 +0000</pubDate>
      <link>https://forem.com/taiseidev26/how-to-remove-a-specific-error-with-angulars-seterrors-4kom</link>
      <guid>https://forem.com/taiseidev26/how-to-remove-a-specific-error-with-angulars-seterrors-4kom</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When building forms in Angular, have you ever faced this situation?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I want to remove only a specific validation error,&lt;br&gt;
but I want to keep the others."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The built-in &lt;code&gt;setErrors()&lt;/code&gt; method in Angular makes this harder than expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Common Scenario
&lt;/h2&gt;

&lt;p&gt;Consider a product search form with a price range.&lt;br&gt;
The user inputs &lt;strong&gt;minPrice&lt;/strong&gt; and &lt;strong&gt;maxPrice&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The form requires these validations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Both fields are required (&lt;code&gt;required&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Values must be at least 0 (&lt;code&gt;min&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;minPrice &amp;lt;= maxPrice&lt;/code&gt; must hold&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  A Problematic Implementation
&lt;/h2&gt;

&lt;p&gt;Validation rule #3 needs a custom validator.&lt;br&gt;
Many developers try something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// All errors are cleared&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;minPrice&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;maxPrice&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setErrors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What's Wrong?
&lt;/h2&gt;

&lt;p&gt;Calling &lt;code&gt;setErrors(null)&lt;/code&gt; clears all errors.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you only wanted to remove &lt;code&gt;customError&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;required&lt;/code&gt; and &lt;code&gt;min&lt;/code&gt; are also removed.&lt;br&gt;
As a result, important error messages disappear.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Does This Happen?
&lt;/h2&gt;

&lt;p&gt;It's because of how Angular's &lt;code&gt;setErrors&lt;/code&gt; works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;setErrors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ValidationErrors&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;opts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;emitEvent&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Pass a &lt;code&gt;ValidationErrors&lt;/code&gt; object -&amp;gt; replaces current errors&lt;/li&gt;
&lt;li&gt;Pass &lt;code&gt;null&lt;/code&gt; -&amp;gt; means "no errors"&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution: Remove Only a Specific Error
&lt;/h2&gt;

&lt;p&gt;The safe approach has three steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get the current errors&lt;/li&gt;
&lt;li&gt;Delete only the target error&lt;/li&gt;
&lt;li&gt;Reset with remaining errors (or &lt;code&gt;null&lt;/code&gt; if empty)&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;customError&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setErrors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Result: { required: true, min: true }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Using &lt;code&gt;setErrors(null)&lt;/code&gt; blindly may clear needed errors&lt;/p&gt;

&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;setErrors&lt;/code&gt; replaces all existing errors&lt;/li&gt;
&lt;li&gt;To remove one error, keep others and reset&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this pattern, you can safely handle complex validations.&lt;/p&gt;

</description>
      <category>angular</category>
    </item>
    <item>
      <title>First Post on Dev.to!</title>
      <dc:creator>Taisei</dc:creator>
      <pubDate>Sun, 31 Aug 2025 12:25:40 +0000</pubDate>
      <link>https://forem.com/taiseidev26/first-post-on-devto-3j36</link>
      <guid>https://forem.com/taiseidev26/first-post-on-devto-3j36</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hello, I'm Taisei!&lt;br&gt;
&lt;strong&gt;I work as a sofftware engineer in Japan.&lt;/strong&gt;🇯🇵&lt;/p&gt;

&lt;p&gt;There are two main reasons why I started writing on Dev.to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I want to improve my technical skills in English.&lt;/li&gt;
&lt;li&gt;I want to build a career overseas.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;I faced a problem in Angular Material that I couldn't solve.&lt;br&gt;
So, I checked the issues on GitHub.&lt;br&gt;
There, engineers were having active discussions in English.&lt;/p&gt;

&lt;p&gt;At that moment, I felt strongly：”This is an unknown world.”&lt;/p&gt;

&lt;p&gt;I have never been abroad and I don't have foreign friends.&lt;br&gt;
That's why I want to combine programming, our common language, with English.&lt;br&gt;
I want to jump into the place where engineers around the world debate on Github.&lt;/p&gt;

&lt;p&gt;I don't want to rely only on translation tools.&lt;br&gt;
I want to connect heart to heart as fellow engineers.&lt;br&gt;
This feeling pushed me to take my first step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background and Skills
&lt;/h2&gt;

&lt;p&gt;I started my career by coding websites and have been working as a frontend engineer for about 4 years. Currently, I'm involved in the development and operation of a membership-based online service for a major manufacturer.&lt;/p&gt;

&lt;p&gt;The main technologies I use are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TypeScript
&lt;/li&gt;
&lt;li&gt;Angular
&lt;/li&gt;
&lt;li&gt;Python
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;My English writing is still rough.&lt;br&gt;
But I believe constant challenges will make me stronger.&lt;br&gt;
I'd love to connect with people who also aim for growth.&lt;br&gt;
Let's learn and improve together!&lt;/p&gt;

</description>
      <category>learning</category>
      <category>career</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
