<?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>DEV Community: codpro sui</title>
    <description>The latest articles on DEV Community by codpro sui (@codpro_sui).</description>
    <link>https://dev.to/codpro_sui</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%2F3788371%2F71d364fd-917f-4dda-92b0-8669ea82e0cf.png</url>
      <title>DEV Community: codpro sui</title>
      <link>https://dev.to/codpro_sui</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codpro_sui"/>
    <language>en</language>
    <item>
      <title>codpro-validator react form validator library</title>
      <dc:creator>codpro sui</dc:creator>
      <pubDate>Tue, 24 Feb 2026 05:35:22 +0000</pubDate>
      <link>https://dev.to/codpro_sui/codpro-validator-react-form-validator-library-1b3g</link>
      <guid>https://dev.to/codpro_sui/codpro-validator-react-form-validator-library-1b3g</guid>
      <description>&lt;p&gt;Hi coders 👋,&lt;br&gt;
I recently built my own form validation library for React instead of using heavy libraries. I wanted something lightweight, flexible, and easy to control — so I decided to build it from scratch.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Not Use Existing Libraries?
&lt;/h2&gt;

&lt;p&gt;While working with forms in React, I explored popular solutions. They are powerful, but I faced a few issues:&lt;br&gt;
Too much boilerplate&lt;br&gt;
Large bundle size&lt;br&gt;
Complex configuration for simple forms&lt;br&gt;
Limited flexibility for custom validation logic&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;
&lt;h2&gt;
  
  
  Install first package 📦 from npm
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install codpro-validator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Uses
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {
  values,
  errors,
  handleChange,
  handleSubmit,
  isDirty,
  isSubmitting
} = useValidator({
   name:{
 rules:[min(6,message)],
disabled: true // false
},{mode:"onChange"} //while typinge check err // onSubmit, onBlur when leave the input box
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  register
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form onSubmit={handleSubmit(onSubmit)}&amp;gt;
      &amp;lt;input {...register("email")} placeholder="Email" /&amp;gt;
      {errors.email &amp;amp;&amp;amp; &amp;lt;p&amp;gt;{errors.email}&amp;lt;/p&amp;gt;}

      &amp;lt;input type="password" {...register("password")} placeholder="Password" /&amp;gt;
      {errors.password &amp;amp;&amp;amp; &amp;lt;p&amp;gt;{errors.password}&amp;lt;/p&amp;gt;}

      &amp;lt;input type="password" {...register("confirmPassword")} placeholder="Confirm Password" /&amp;gt;
      {errors.confirmPassword &amp;amp;&amp;amp; &amp;lt;p&amp;gt;{errors.confirmPassword}&amp;lt;/p&amp;gt;}

      &amp;lt;button disabled={!isDirty || isSubmitting}&amp;gt;
        {isSubmitting ? "Submitting..." : "Submit"}
      &amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note:&lt;br&gt;
Suppose if you want to define initial value you can use defaultValue? Of react attribute. &lt;/p&gt;

&lt;p&gt;Lightweight library, easy to read, easy to write ✍️, performance better, high security checking, &lt;br&gt;
Must define mode:?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
