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

# Validate an order

> Validate an order

This endpoint validates

* The province is correct for the provided country
* The variants can be shipped to the provided country
* The phone number is valid
* The zip code is valid
* The taxNumber field
  * It is supposed to be there for the provided country
  * It is formatted correctly and passes regex validation

This endpoint does not currently check the validity of the address itself.

Phone number validation is done with [libphonenumber-js](https://www.npmjs.com/package/libphonenumber-js).

[Here](https://catamphetamine.gitlab.io/libphonenumber-js/) is a demo page of the phone validation for further testing.

<Tip>Partners must pass in the companyId field in the body</Tip>

## Tax number

For Brazil, Mexico, China, Italy, and South Korea you must pass in an additional taxNumber field.
For Brazil the tax number field must pass regex validation as follows

```javascript theme={null}
new RegExp(`^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$`).test(taxNumber)
```

For Mexico the pattern is 13 characters (4 letters followed by 6 digits and 3 alphanumeric characters).

```javascript theme={null}
new RegExp(`^[A-Za-z]{4}\\d{6}[A-Za-z0-9]{3}$`).test(taxNumber)
```

For China, Italy, and South Korea there is no validation run on the taxNumber field.

## CustomAttributes

Custom attribute field is deprecated. Please use the taxNumber field instead


## OpenAPI

````yaml post /api/ext/v1/collection/{collectionId}/orders/validate-order
openapi: 3.0.1
info:
  title: Covver External API docs
  description: Covver External API docs
  version: 0.1.0
servers:
  - url: https://staging-api.covver.io
    description: Covver Staging Server
  - url: https://api.covver.io
    description: Covver Production Server
  - url: http://localhost:8080
    description: Covver Local Server
security:
  - BearerAuth: []
tags:
  - name: Auth
    description: Authentication endpoints
  - name: Products
    description: Product endpoints
  - name: People
    description: People endpoints
  - name: Orders
    description: Orders endpoints
  - name: Reports
    description: Report endpoints
externalDocs:
  url: https://swagger.io
  description: Find more info here
paths:
  /api/ext/v1/collection/{collectionId}/orders/validate-order:
    post:
      tags:
        - Orders
      summary: Validate an order
      description: Validate an order
      parameters:
        - schema:
            format: uuid
            type: string
          in: path
          name: collectionId
          required: true
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                companyId:
                  description: Required for partners
                  type: string
                orderItems:
                  type: array
                  items:
                    type: object
                    properties:
                      variantId:
                        type: string
                      quantity:
                        type: number
                    required:
                      - variantId
                      - quantity
                taxNumber:
                  type: string
                customAttributes:
                  type: array
                  items:
                    type: object
                    properties:
                      key:
                        type: string
                      value:
                        type: string
                    required:
                      - key
                      - value
                orderNumber:
                  type: string
                address:
                  additionalProperties: false
                  type: object
                  properties:
                    address1:
                      maxLength: 35
                      description: 'Max length: 35'
                      type: string
                    city:
                      description: 'Max length: 35'
                      type: string
                    countryCode:
                      type: string
                    phone:
                      type: string
                    province:
                      type: string
                    provinceCode:
                      type: string
                    customAttributes:
                      type: array
                      items:
                        type: object
                        properties:
                          key:
                            type: string
                          value:
                            type: string
                        required:
                          - key
                          - value
                    address2:
                      maxLength: 35
                      description: 'Max length: 35'
                      default: ''
                      type: string
                    zip:
                      maxLength: 16
                      description: 'Max length: 16'
                      default: ''
                      type: string
                    country:
                      description: Deprecated, only countryCode is necessary
                      type: string
                  required:
                    - address1
                    - city
                    - countryCode
                    - phone
                    - address2
                shouldValidateProvinceCode:
                  type: boolean
              required:
                - address
        required: true
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                required:
                  - success
                nullable: true
        4XX:
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errorCode:
                    type: string
                  error: {}
                  statusCode:
                    type: number
                required:
                  - message
                  - errorCode
                  - statusCode
        5XX:
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  errorCode:
                    type: string
                  error: {}
                  statusCode:
                    type: number
                required:
                  - message
                  - errorCode
                  - statusCode
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````