-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the test.mosquitto.org URL in the MQTT settings #829
- Loading branch information
Showing
6 changed files
with
32 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import Schema from 'async-validator'; | ||
import { MqttSettings } from '../types'; | ||
import { IP_OR_HOSTNAME_VALIDATOR } from './shared'; | ||
|
||
export const MQTT_SETTINGS_VALIDATOR = new Schema({ | ||
host: [{ required: true, message: 'Host is required' }, IP_OR_HOSTNAME_VALIDATOR], | ||
base: { required: true, message: 'Base is required' }, | ||
port: [ | ||
{ required: true, message: 'Port is required' }, | ||
{ type: 'number', min: 0, max: 65535, message: 'Invalid Port' } | ||
], | ||
keep_alive: [ | ||
{ required: true, message: 'Keep alive is required' }, | ||
{ type: 'number', min: 1, max: 86400, message: 'Keep alive must be between 1 and 86400' } | ||
], | ||
publish_time_heartbeat: [ | ||
{ required: true, message: 'Heartbeat is required' }, | ||
{ type: 'number', min: 10, max: 86400, message: 'Heartbeat must be between 10 and 86400' } | ||
] | ||
}); | ||
export const createMqttSettingsValidator = (mqttSettings: MqttSettings) => | ||
new Schema({ | ||
...(mqttSettings.enabled && { | ||
host: [{ required: true, message: 'Host is required' }, IP_OR_HOSTNAME_VALIDATOR], | ||
base: { required: true, message: 'Base is required' }, | ||
port: [ | ||
{ required: true, message: 'Port is required' }, | ||
{ type: 'number', min: 0, max: 65535, message: 'Invalid Port' } | ||
], | ||
keep_alive: [ | ||
{ required: true, message: 'Keep alive is required' }, | ||
{ type: 'number', min: 1, max: 86400, message: 'Keep alive must be between 1 and 86400' } | ||
], | ||
publish_time_heartbeat: [ | ||
{ required: true, message: 'Heartbeat is required' }, | ||
{ type: 'number', min: 10, max: 86400, message: 'Heartbeat must be between 10 and 86400' } | ||
] | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters