You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui/packages/consul-ui/app/validations/intention.js

20 lines
757 B

import { validatePresence, validateLength } from 'ember-changeset-validations/validators';
import validateSometimes from 'ember-changeset-conditional-validations/validators/sometimes';
export default {
'*': validateSometimes([validatePresence(true)], function() {
const action = this.get('Action') || '';
const permissions = this.get('Permissions') || [];
if (action === '' && permissions.length === 0) {
return true;
}
return false;
}),
SourceName: [validatePresence(true), validateLength({ min: 1 })],
DestinationName: [validatePresence(true), validateLength({ min: 1 })],
Permissions: [
validateSometimes([validateLength({ min: 1 })], function(changes, content) {
return !this.get('Action');
}),
],
};