2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2018-06-06 11:00:25 +00:00
|
|
|
import { validatePresence, validateLength } from 'ember-changeset-validations/validators';
|
2023-02-10 21:32:19 +00:00
|
|
|
import validateSometimes from 'consul-ui/validations/sometimes';
|
2020-07-09 09:08:47 +00:00
|
|
|
export default {
|
2023-02-10 21:32:19 +00:00
|
|
|
'*': [
|
|
|
|
validateSometimes(validatePresence(true), function () {
|
|
|
|
const action = this.get('Action') || '';
|
|
|
|
const permissions = this.get('Permissions') || [];
|
|
|
|
if (action === '' && permissions.length === 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}),
|
|
|
|
],
|
2020-07-09 09:08:47 +00:00
|
|
|
SourceName: [validatePresence(true), validateLength({ min: 1 })],
|
|
|
|
DestinationName: [validatePresence(true), validateLength({ min: 1 })],
|
2020-09-30 11:33:01 +00:00
|
|
|
Permissions: [
|
2023-02-10 21:32:19 +00:00
|
|
|
validateSometimes(validateLength({ min: 1 }), function (changes, content) {
|
2020-09-30 11:33:01 +00:00
|
|
|
return !this.get('Action');
|
|
|
|
}),
|
|
|
|
],
|
2020-07-09 09:08:47 +00:00
|
|
|
};
|