Skip to content

Commit 9db551e

Browse files
fix(FirewallAlias): fix 'detail' auto-generation
This commit fixes an issue that prevented the 'detail' field values from auto populating when not provided.
1 parent c2834dd commit 9db551e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/FirewallAlias.inc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ class FirewallAlias extends Model {
131131
}
132132

133133
/**
134-
* Adds custom validation to `detail` field
135-
* @param string $detail The incoming value to be validated.
134+
* Adds extra validation to the entire model. This is primarily used to ensure the `detail` field automatically
135+
* creates entries to match the number of `address` entries if there are not enough, or throws an error if there
136+
* are too many.
136137
* @returns string The validated value to be set.
137-
* @throws ValidationError When the `detail` value is invalid.
138+
* @throws ValidationError When the `detail` array has too many entries.
138139
*/
139-
public function validate_detail(string $detail): string {
140+
public function validate_extra(): void {
140141
# Throw an error if there are more `detail` items than `address` items
141142
if (count($this->detail->value) > count($this->address->value)) {
142143
throw new ValidationError(
@@ -149,8 +150,6 @@ class FirewallAlias extends Model {
149150
while (count($this->detail->value) < count($this->address->value)) {
150151
$this->detail->value[] = 'Entry added ' . date('r');
151152
}
152-
153-
return $detail;
154153
}
155154

156155
/**

0 commit comments

Comments
 (0)