Skip to main content
When creating a Nash order, Nash applies these validations to ensure it’s valid.

Address & location validation

  • Address input exclusivity:
    • An error is raised if you provide both pickupAddress and pickupPlaceId (or the dropoff equivalents). You must use one or the other.
    • An error is raised if you provide address components (e.g., pickupAddressFormattedStreet) along with pickupAddress or pickupPlaceId.
  • Address input requirement: If no store location ID is provided, it requires one of the following for both pickup and dropoff:
    1. A single-line address string (pickupAddress / dropoffAddress).
    2. A Google Place ID (pickupPlaceId / dropoffPlaceId).
    3. A set of address components (street, city, zip, etc.).
    • If none of these are present, a “required field” error is added for the address.
  • Store location logic:
    • If a pickupStoreLocationId or pickupExternalStoreLocationId is provided, it attempts to find the corresponding store location.
    • Existence check: It fails if the store location ID does not exist for that organization or if the store has been deleted.
    • Automatic store creation: If an external store location ID is given but not found, it checks an organization preference for automatically creating store locations. If enabled, it attempts to create a new store location using the order’s pickup details.
    • Default field population: If a valid pickup store location is found, it automatically populates the order’s pickup fields (name, phone, email, instructions) with the data from the store, unless those fields were already provided in the request.
  • Geocoding and parsing:
    • If a raw pickupAddress or dropoffAddress string is provided, it attempts to parse it and geocode it to get coordinates (latitude/longitude). It will raise an error if parsing fails (e.g., “Address not found”).
    • It performs the same parsing and geocoding for pickupPlaceId and dropoffPlaceId.
  • Identical location check:
    • It checks if the pickupPlaceId and dropoffPlaceId are the same. If so, it raises an error.
    • After parsing, it compares the final parsed pickup and dropoff address components. If they are identical, it raises an error.
  • Cross-country check: Fails if the parsed pickupAddressCountry and dropoffAddressCountry are not the same.
  • Distance check:
    • Calculates the straight-line distance between the pickup and dropoff coordinates.
    • It checks against an organization-specific maximum delivery distance preference and fails if the distance exceeds it.

Required & conditional fields

  • Core required fields: Checks that a value is present for: valueCents, pickupPhoneNumber, dropoffPhoneNumber, deliveryMode.
  • Contact name requirement:
    • Requires either pickupFirstName or pickupBusinessName to be present.
    • Requires either dropoffFirstName or dropoffBusinessName to be present.

Data type & format validation

  • Integer fields: Verifies that valueCents, tipAmountCents, and itemsCount are valid integers.
  • Float/decimal fields: Verifies that dimensional fields (weight, height, width, depth, volume) are valid decimal numbers and are greater than 0.
  • Order value: Checks that valueCents is greater than 0.
  • Item count: Checks that itemsCount, if provided, is at least 1.
  • Name fields: Checks that all name fields (pickupFirstName, etc.) are strings and do not exceed a maximum length (80 characters).
  • Phone numbers:
    • Checks that pickupPhoneNumber and dropoffPhoneNumber are valid phone numbers for the corresponding country.
    • If the number is invalid but the organization has a default backup phone number configured, it will use the backup number instead of failing.
  • Items: If the items field is provided, it validates that each entry in the list is a valid item structure.
  • Order metadata:
    • It validates that the dictionary has no more than 15 key-value pairs and that all values are simple scalar types (string, int, float, bool).

Enum & ID validation

  • Delivery mode:
    • Ensures deliveryMode is one of the allowed values (now or scheduled).
    • If mode is now, it nullifies all datetime fields.
    • If mode is scheduled, it requires at least one of the datetime fields (pickupStartTime, etc.) to be set.
  • Currency:
    • If a currency is provided, it ensures it’s in the list of supported currencies.
    • If no currency is provided, it attempts to infer it from the pickupAddressCountry.
  • Requirements: Ensures all provided requirements are supported (see Order Requirements), unless it’s a custom: requirement.
  • Vehicle size: Ensures minimumVehicleSize is one of the supported vehicle sizes.
  • Dispatch strategy: If dispatchStrategyId is provided, it confirms that it exists, belongs to the organization, and is not deleted.
  • Delivery window: If deliveryWindowId is provided, it checks if it’s a valid, active window.
  • External ID uniqueness: If an externalId is given, it ensures no other order within the same organization already uses that ID.

Datetime validation

  • Parsing: Attempts to parse all provided datetime strings (pickupStartTime, pickupEndTime, dropoffStartTime, dropoffEndTime) into proper datetime objects. It can handle UTC or timezone-localized inputs based on an order flag. Fails if a string is not a valid date format.
  • Chronological order:
    • pickupStartTime must be earlier than pickupEndTime.
    • dropoffStartTime must be earlier than dropoffEndTime.
    • pickupStartTime must be earlier than dropoffEndTime.
    • pickupEndTime must be earlier than dropoffEndTime.