Skip to content

Commit 934ea49

Browse files
change: [UIE-8841] - custom validation for net_buffer_length (linode#12126)
* change: [UIE-8841] - custom validation for net_buffer_length * Added changeset: DBaaS: Custom validation for `net_buffer_length`
1 parent 31f0268 commit 934ea49

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/validation": Added
3+
---
4+
5+
DBaaS: Custom validation for `net_buffer_length` ([#12126](https://github.com/linode/manager/pull/12126))

packages/validation/src/databases.schema.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,16 @@ const applyConstraints = (validator: any, key: string, field: any) => {
131131
validator = validator.required('timezone cannot be empty');
132132
}
133133
}
134-
134+
if (key === 'net_buffer_length') {
135+
validator = validator.test(
136+
'is-multiple-of-1024',
137+
`${key} must be a multiple of 1024`,
138+
(value: boolean | number | string) => {
139+
if (typeof value !== 'number') return false;
140+
return value % 1024 === 0;
141+
},
142+
);
143+
}
135144
return validator;
136145
};
137146

0 commit comments

Comments
 (0)