mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
f263fbcba2
* Adds shard input to Configure Pack Query Form * Adds shard to API client * Adds shard attribute to scheduled queries list
36 lines
799 B
JavaScript
36 lines
799 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 = 'Interval must be present';
|
|
}
|
|
|
|
if (formData.interval && !validateNumericality(formData.interval)) {
|
|
errors.interval = 'Interval must be a number';
|
|
}
|
|
|
|
if (!formData.logging_type) {
|
|
errors.logging_type = 'A Logging Type must be selected';
|
|
}
|
|
|
|
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;
|