mirror of
https://github.com/empayre/fleet.git
synced 2024-11-08 01:38:57 +00:00
05691d49ca
- Schedule page functionality: Create (modal), delete (modal), view schedule, advanced options - Replaces Packs tab with Schedules tab - Updates e2e tests, mocks, stubs, etc - Defaults logging type to snapshot for packs - Adds conversion helpers and tests helper functions - Adds global_scheduled_queries to redux
34 lines
813 B
JavaScript
34 lines
813 B
JavaScript
import { size } from "lodash";
|
|
|
|
import validateNumericality from "components/forms/validators/validate_numericality";
|
|
|
|
const validate = (formData) => {
|
|
const errors = {};
|
|
|
|
if (!formData.query_id) {
|
|
errors.query_id = "A query must be selected";
|
|
}
|
|
|
|
if (!formData.interval) {
|
|
errors.interval = "Frequency (seconds) must be present";
|
|
}
|
|
|
|
if (formData.interval && !validateNumericality(formData.interval)) {
|
|
errors.interval = "Frequency must be a number";
|
|
}
|
|
|
|
// logging_type does not need to be validated because it is defaulted "snapshot" if unspecified.
|
|
|
|
if (formData.shard) {
|
|
if (formData.shard < 0 || formData.shard > 100) {
|
|
errors.shard = "Shard must be between 0 and 100";
|
|
}
|
|
}
|
|
|
|
const valid = !size(errors);
|
|
|
|
return { valid, errors };
|
|
};
|
|
|
|
export default validate;
|