> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mangopay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Validate the format of User data

This endpoint allows you to check that the format of the `CompanyNumber` is correct and retrieve the validation rules applied to it.

The `CompanyNumber` must be in the correct format for Business Legal Users to be KYC/B verified.

<Warning>
  **Caution – Veracity of data checked during verification**

  This endpoint only checks that the format of the data corresponds to that which is expected. Whether or not the data is true and correct for the specific User is checked during the user verification process when documents are submitted.
</Warning>

### Body parameters

<ParamField body="CompanyNumber" type="object">
  Information about the registration number of a legal entity. For details, see the [Company number](/guides/users/verification/company-number) article.

  <Expandable title="properties">
    <ParamField body="CompanyNumber" type="string" required>
      The registration number of a legal entity, assigned by the relevant national authority.

      **Note:** Any non-alphanumeric characters, like dashes or spaces, are removed before applying the validation rules.
    </ParamField>

    <ParamField body="CountryCode" type="string" required>
      Format: Two-letter country code ([ISO 3166-1 alpha-2 format](/api-reference/overview/data-formats))

      The country of the registration of the legal entity, against which the company number format is validated.
    </ParamField>
  </Expandable>
</ParamField>

### Responses

<AccordionGroup>
  <Accordion title="200 - Valid format for the country">
    <ResponseField name="CompanyNumber" type="string">
      Information about the registration number of a legal entity. For details, see the [Company number](/guides/users/verification/company-number) article.

      <Expandable title="properties">
        <ResponseField name="CompanyNumber" type="string">
          The registration number of a legal entity, assigned by the relevant national authority.

          **Note:** Any non-alphanumeric characters, like dashes or spaces, are removed before applying the validation rules.
        </ResponseField>

        <ResponseField name="CountryCode" type="string">
          Format: Two-letter country code ([ISO 3166-1 alpha-2 format](/api-reference/overview/data-formats))

          The country of the registration of the legal entity, against which the company number format is validated.
        </ResponseField>

        <ResponseField name="IsValid" type="boolean">
          Whether the format of the value is valid for the country.
        </ResponseField>

        <ResponseField name="ValidationRules" type="array">
          The list of regular expressions applicable to the country. Rules only exist for countries listed in the [Company number](/guides/users/verification/company-number) article.

          **Note:** Any non-alphanumeric characters, like dashes or spaces, are removed before applying the validation rules.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="400 - Country code not recognized">
    ```json theme={null}
    {
        "Message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
        "Type": "param_error",
        "Id": "0421656b-5f32-4475-874c-561449f9ffbf",
        "Date": 1697101284.0,
        "errors": {
            "CompanyNumber.CountryCode": "The requested value is not an ISO 3166-1 alpha-2 code which is expected."
        }
    }  
    ```
  </Accordion>
</AccordionGroup>

<ResponseExample>
  ```json 200 - Valid format for the country   theme={null}
  {
      "CompanyNumber": {
          "CompanyNumber": "12345678",
          "CountryCode": "GB",
          "IsValid": true,
          "ValidationRules": [
              "^[0-9]{8}$|^[0-9]{7}$|^SC[0-9]{6}$|^NI[0-9]{6}$|^OC[0-9]{6}$|^R[0-9]{7}$|^IP[0-9]{5}R$|^SO[0-9]{6}$"
          ]
      }
  }
  ```
</ResponseExample>

<RequestExample>
  ```json REST   theme={null}
  {
      "CompanyNumber": {
          "CompanyNumber": "AB123456",
          "CountryCode": "IT"
      }
  }  
  ```

  ```python Python   theme={null}
  import re
  import mangopay

  mangopay.client_id='your-client-id'
  mangopay.apikey='your-api-key'

  from mangopay.api import APIRequest
  handler = APIRequest(sandbox=True)

  from mangopay.resources import LegalUser

  legal_user = LegalUser(
      id = '210602889'
  )

  company_number = str(legal_user.company_number)

  validation_regex = re.compile(r"^[0-9]{11}$|^[a-z]{2}[0-9]{7}$|^[a-z]{2}[0-9]{6}$")
  validate_it = validation_regex.match(company_number)

  print(bool(validate_it))  
  ```
</RequestExample>
