can you do conditional attributes for module type profiles? #20910
-
|
Example JSON: Is there a way to make the 'generation' field only show up if the 'type' option is 'nvme' ? |
Beta Was this translation helpful? Give feedback.
Answered by
jeremystretch
Dec 3, 2025
Replies: 1 comment 1 reply
-
|
Good question! NetBox validates profile attributes using a JSON schema, which does support conditionals. This should work for your example: {
"properties": {
"hot_swappable": {
"default": false,
"title": "Hot-swappable",
"type": "boolean"
},
"size": {
"description": "Raw disk capacity",
"title": "Size (GB)",
"type": "integer"
},
"speed": {
"title": "Speed (RPM)",
"type": "integer"
},
"type": {
"default": "SSD",
"enum": [
"HD",
"SSD",
"NVME"
],
"title": "Disk type",
"type": "string"
},
"generation": {
"enum": [
"Gen3",
"Gen4",
"Gen5"
],
"title": "NVMe Generation",
"type": "string"
}
},
"required": [
"size"
],
"if": {
"properties": {
"type": {
"const": "NVME"
}
}
},
"then": {
"required": ["generation"]
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rconkor
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good question! NetBox validates profile attributes using a JSON schema, which does support conditionals. This should work for your example:
{ "properties": { "hot_swappable": { "default": false, "title": "Hot-swappable", "type": "boolean" }, "size": { "description": "Raw disk capacity", "title": "Size (GB)", "type": "integer" }, "speed": { "title": "Speed (RPM)", "type": "integer" }, "type": { "default": "SSD", "enum": [ "HD", "SSD", "NVME" ], "ti…