yoqw/web/cms/app/services/agent/service.js
2021-11-17 01:01:43 +08:00

81 lines
1.8 KiB
JavaScript

import Service from '../service';
import { isBlank } from '@ember/utils';
export default Service.extend({
modelName: 'Agent',
createConstraints: {
groupId: {
presence: true,
},
name: {
presence: true,
length: {
minimum: 1,
maximum: 36
}
},
account: {
presence: true,
length: {
minimum: 4,
maximum: 36
},
format: {
pattern: /^\w+$/,
message: '仅允许字母数字'
}
},
agent: {
length: function(value) {
if (isBlank(value)) {
return false;
}
return {
minimum: 4,
maximum: 36
};
},
format: function(value) {
if (isBlank(value)) {
return false;
}
return {
pattern: /^[1-9]+\d*$/,
message: '仅允许数字'
};
}
},
wrapUpTime: {
presence: true,
numericality: {
onlyInteger: true,
greaterThan: -1
}
}
},
updateConstraints: {
groupId: {
presence: true
},
name: {
presence: true,
length: {
minimum: 1,
maximum: 36
}
},
wrapUpTime: {
presence: true,
numericality: {
onlyInteger: true,
greaterThan: -1
}
}
},
createBatchConstraints: {
agents: {
presence: true
}
},
});