Reference: Swagger Data Types
A property in OpenAPI specs can be one of the following basic types:
- string (includes dates and files)
- number
- integer
- boolean
- array
- object
OpenAPI provides built-in keywords to specify constraints for properties:
minLength
,maxLength
: Define the allowed length.pattern
: Define a regex pattern (e.g., hex format).
Example:
MPTokenMetadata:
type: string
pattern: '^[0-9A-Fa-f]*$'
description: |
Arbitrary metadata about this issuance, in hex format. The limit for this field is 1024 bytes.
minLength: 0
minimum
,maximum
: Define the range of valid values.
Example:
TradingFee:
type: integer
format: uint16
description: |
(Required) The fee to charge for trades against this AMM instance, in units of 1/100,000.
A value of 1 is equivalent to 0.001%. The maximum value is 1000, indicating a 1% fee.
minimum: 0
maximum: 1000
minItems
,maxItems
: Define the allowed array length.uniqueItems
: Defines the elements must be unique in the array.
Example:
NFTokenOffers:
type: array
items:
type: string
minItems: 1
description: |
An array of IDs of the NFTokenOffer objects to cancel. Each entry must be unique.
Reference: Swagger OpenAPI Extensions
Users can define custom validations using vendor extensions (x-custom-validation
), which allow adding extra constraints beyond standard OpenAPI rules.
Custom validations can be applied on:
- Specific property
- Rules involving combinations of properties
Below are the available validation rules in x-custom-validation
, designed based on the current rippled
API. These rules may evolve as the API expands.
Verifies a valid XRPL base58 account.
Structure:
x-custom-validation:
isAccount: true
Example:
BaseTransaction:
type: object
properties:
Account:
type: string
x-custom-validation:
isAccount: true
Verifies a string field must be numeric.
Structure:
x-custom-validation:
isNumericString: true
Example:
SignatureReward:
type: string
x-custom-validation:
isNumericString: true
Verifies a field can have a special value outside its range.
Structure:
x-custom-validation:
specialValue: 0
Example:
TransferRate:
type: integer
minimum: 1000000000
maximum: 2000000000
x-custom-validation:
specialValue: 0
Verifies a field is in lower case.
Structure:
x-custom-validation:
isLowerCase: true
Example:
Domain:
type: string
format: hex
maxLength: 256
x-custom-validation:
isLowerCase: true
Verifies Amount property is greater than a specified value.
Structure:
x-custom-validation:
amountGreaterThan: 0
Example:
Amount:
type: string
x-custom-validation:
amountGreaterThan: 0
Ensures a field is strictly greater or less than a value. It applies only to integer fields.
Structure:
x-custom-validation:
greaterThan: 0
lessThan: 1000
Example (greaterThan):
LastUpdateTime:
type: integer
x-custom-validation:
greaterThan: 946684799
Verifies two fields that are required together if any is presented.
Structure:
x-custom-validation:
mutualPresence:
- field1: { { fieldname } }
field2: { { fieldname } }
Example:
x-custom-validation:
mutualPresence:
- field1: Condition
field2: Fulfillment
Verifies requiredFields must be specified if dependentField is not empty.
Structure:
x-custom-validation:
dependentPresence:
- dependentField: { { fieldname } }
requiredFields:
- { { fieldname } }
- { { fieldname } }
Example:
x-custom-validation:
dependentPresence:
- dependentField: NFTokenBrokerFee
requiredFields:
- NFTokenSellOffer
- NFTokenBuyOffer
Verifies if one field is set, then the other must not be set.
Structure:
x-custom-validation:
mutualExclusion:
- field1: { { fieldname } }
field2: { { fieldname } }
Example:
x-custom-validation:
mutualExclusion:
- field1: Amount
field2: DeliverMin
Verifies two fields must have different values.
Structure:
x-custom-validation:
isDifferent:
- field1: { { fieldname } }
field2: { { fieldname } }
Example:
x-custom-validation:
isDifferent:
- field1: Issuer
field2: Account
Verify at least one within a set of fields is required.
Structure:
x-custom-validation:
requireOneOf:
- fields:
- { { fieldname } }
- { { fieldname } }
message: 'Require at-least one of these fields.'
Example:
x-custom-validation:
requireOneOf:
- fields:
- LPTokenOut
- Amount
message: 'Require at-least one of these LPTokenOut or Amount.'
Verifies that exactly one field is present.
Structure:
x-custom-validation:
requireExactlyOne:
- fields:
- { { fieldname } }
- { { fieldname } }
message: 'Exactly one field must be present.'
Example:
x-custom-validation:
requireExactlyOne:
- fields:
- Authorize
- AuthorizeCredentials
- Unauthorize
- UnauthorizeCredentials
message: 'You must provide exactly one of Authorize, AuthorizeCredentials, Unauthorize, or UnauthorizeCredentials.'
Verifies a field must (must not) be set if a flag is set/not set.
Example (conditionalRequiredOnFlag):
If tfSellNFToken is not set on Flags then Owner field must be present.
conditionalRequiredOnFlag:
- requiresFlag: tfSellNFToken
flagField: Flags
condition: false
field: Owner
message: 'Must be present for buy offers.'
Example (conditionalForbiddenOnFlag):
If asfAuthorizedNFTokenMinter is not set on SetFlag then NFTokenMinter field must be absent.
conditionalForbiddenOnFlag:
- requiresFlag: asfAuthorizedNFTokenMinter
flagField: SetFlag
condition: false
field: NFTokenMinter
message: 'NFTokenMinter must not be set if asfAuthorizedNFTokenMinter is not present.'
Verifies a field must be greater than or less than if a flag is set/not set.
Example (conditionalGreaterThanOnFlag):
If tfSellNFToken is not set on Flags then Amount field must be greater than 0.
conditionalGreaterThanOnFlag:
- requiresFlag: tfSellNFToken
flagField: Flags
condition: false
field: Amount
value: 0
message: 'Must be greater than 0 for a buy offer.'
Example (conditionalLessThanOnFlag):
If tfSellNFToken is set on Flags then Amount field must be less than 0.
conditionalLessThanOnFlag:
- requiresFlag: tfSellNFToken
flagField: Flags
condition: true
field: Amount
value: 0
message: 'Must be less than 0.'
Verifies that only one flag in the list can be set.
Structure:
x-custom-validation:
flagConflict:
- flagField: Flags
flags:
- { { flag1 } }
- { { flag2 } }
Example:
x-custom-validation:
flagConflict:
- flagField: Flags
flags:
- tfMPTLock
- tfMPTUnlock
Verifies two amount fields must be XRP-XRP or IOU-IOU.
Structure:
x-custom-validation:
matchingCurrencyType:
- field1: { { fieldname } }
field2: { { fieldname } }
Example:
x-custom-validation:
matchingCurrencyType:
- field1: XChainBridge.IssuingChainIssue
field2: XChainBridge.LockingChainIssue
Verifies an amount field must not be XRP.
Structure:
x-custom-validation:
notXRPAmount:
field: { { fieldname } }
Example:
x-custom-validation:
notXRPAmount:
- field: Amount
If none of the above rules apply, users can define custom validation rules.
Example:
x-custom-validation:
validate{{tx_name}}:
- message: 'specified rules here'
This document provides a structured set of validation rules for OpenAPI specs. Users and maintainers can extend these rules as the API evolves.