title: Implementing reusable methods for Ant Design validator (ReactJS)
body: <p>I am trying to implement a validator as per the documentation provided by ant design <a href="https://ant.design/components/form/" rel="nofollow noreferrer">https://ant.design/components/form/</a></p>
  
  <p>The methods are working when they are placed in the same class/component.
  The validator method uses a callback method that throws a string where the validation method was called.</p>
  
  <p>What i am trying to achieve is that i want the same validator method to be reuseable. When I placed them in another class it's not working.</p>
  
  <p>I have tried moving it to a different class and export the method. On importing the method in the same component callback is not working.</p>
  
  <p>Here is my method that I am using for validation: </p>
  
  <pre><code>mobileCountryCodeValidator = (rule, value, callback) =&gt; {
      const { getFieldValue } = this.props.form
      let countryCode = getFieldValue('phoneCountryCode')
      if (countryCode === '92') {
        if (value.substring(0, 1) !== '3') {
          callback('Number should start with 3 for Pakistan.')
        }
        callback()
      } else if (countryCode === '966') {
        if (value.substring(0, 2) !== '05') {
          callback('Number should start with 05 for Saudi Arabia.')
        }
        callback()
      }
    }
  </code></pre>
  
  <p>This is where I am calling the above method.</p>
  
  <pre><code>&lt;FormItem validateStatus="validating"&gt;
      {getFieldDecorator('phoneNumber', {rules: [
          { required: true, message: 'Please input your phone number.' },
          { len: 10, message: 'Phone number should be 10 digits long.' },
          { validator: this.numbersValidator },
          { validator: this.mobileCountryCodeValidator },
       ]})(
            &lt;Input placeholder="Enter Mobile Number" /&gt;
       )}
  &lt;/FormItem&gt;
  </code></pre>
  
  <p>So what I am expecting is that how should I be able to move the <code>mobileCountryCodeValidator</code> method to another class so It can become a reuseable method. So I would be able to use them in other components too.</p>