Custom Fields
A Custom Field represents a single field of data (for example a Product Rating). A Custom API is composed of one or more Custom Fields.
Here is a comparison of different types and validation available in Custom APIs vs Non-Core Flows.
Feature | Non-Core Flows | Commerce Extensions |
---|---|---|
Data Type: String | ✅ | ✅ |
Data Type: Integer | ✅ | ✅ |
Data Type: Float | ✅ | ✅ |
Data Type: Boolean | ✅ | ✅ |
Data Type: Date | ✅ | ✅ Regex possible now, full support planned |
Data Type: One To Many | ✅ | Planned |
Validation: Regular Expression | ⛔️ | Planned |
Validation: Slug/Email | ✅ | ✅ Replaced by Regex validation |
Validation: Min/Max Value | ✅ | ✅ |
Validation: Enum(String) | ✅ | ✅ Replaced by Regex validation |
Validation: Enum(Float/Integer) | ✅ | ⛔️ |
Validation
validation
can optionally be used to limit the values that can be stored in an object. Each validation attribute is optional, ie. you can set min_value
but leave max_value
as null
to leave the maximum value unbounded.
Integer Validation
min_value
: Specifies the minimum whole number that can be stored. If set, it must be less thanmax_value
.max_value
: Specifies the maximum whole number that can be stored. If set, it must be greater thanmin_value
.
sample integer validation object:
"validation": {
"integer": {
"min_value": 0,
"max_value": 32
}
}
Even if no validation is set, field_type integer
only supports values between -2^53+1 and 2^53+1.
Float Validation
min_value
: Specifies the minimum number that can be stored. If set, it must be less thanmax_value
.max_value
: Specifies the maximum number that can be stored. If set, it must be greater thanmin_value
.
sample float validation object:
"validation": {
"float": {
"min_value": 0.01,
"max_value": 32.01
}
}
The float
field_type cannot accurately represent some numbers and so using very small or large numbers might lose precision. We recommend that API clients use either the integer
field_type if applicable , or the string
data type if perfect precision or recall is required.
String Validation
min_length
: Specifies the minimum number of characters that can be stored. If set, it must be less than 0 and less thanmax_length
.max_length
: Specifies the maximum number of characters that can be stored. If set, it must be greater than 0 andmin_length
.regex
: RE2 regular expression that used to restrict the specific characters that can be stored. This must be less than 1024 characters.
sample string validation object:
"validation": {
"string": {
"min_length": 0,
"max_length": 64
"regex": "^.+\.(jpg|jpeg|png|gif|pdf)$"
}
}
Even if no validation is set, field_type string
only supports values that are up to 65535
characters long.
Reserved Slugs
The following values cannot be used as a slug
in a Custom Field.
- slug
- type
- id
- meta
- created_at
- updated_at
- links
- relationships
- attributes
- attribute
- dimension
- dimensions
- weight
- weights
📄️ Create a Custom Field
Create a Custom Field
📄️ Get all Custom Fields
## Filtering
📄️ Get a Custom Field
Get a Custom Field
📄️ Update a Custom Field
Update a Custom Field
📄️ Delete a Custom Field
Delete a Custom Field