56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const assert_1 = require("oak-domain/lib/utils/assert");
|
|
const validator_1 = require("oak-domain/lib/utils/validator");
|
|
const types_1 = require("oak-domain/lib/types");
|
|
const validator_2 = require("oak-domain/lib/utils/validator");
|
|
const user_1 = require("../utils/user");
|
|
const Exception_1 = require("../types/Exception");
|
|
const checkers = [
|
|
{
|
|
type: 'data',
|
|
action: 'create',
|
|
entity: 'mobile',
|
|
checker: (data) => {
|
|
(0, assert_1.assert)(!(data instanceof Array));
|
|
(0, validator_2.checkAttributesNotNull)('mobile', data, ['mobile']);
|
|
if (!(0, validator_1.isMobile)(data.mobile)) {
|
|
throw new types_1.OakInputIllegalException('mobile', ['mobile'], '手机号非法');
|
|
}
|
|
},
|
|
},
|
|
{
|
|
type: 'data',
|
|
action: 'update',
|
|
entity: 'mobile',
|
|
checker: (data) => {
|
|
(0, assert_1.assert)(!(data instanceof Array));
|
|
if (data.hasOwnProperty('mobile')) {
|
|
(0, validator_2.checkAttributesNotNull)('mobile', data, ['mobile']);
|
|
if (!(0, validator_1.isMobile)(data.mobile)) {
|
|
throw new types_1.OakInputIllegalException('mobile', ['mobile'], '手机号非法');
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
type: 'row',
|
|
action: 'remove',
|
|
entity: 'mobile',
|
|
filter(operation, context) {
|
|
const isRoot = context.isRoot();
|
|
if (isRoot) {
|
|
return undefined;
|
|
}
|
|
const filter = (0, user_1.getUserSafetyFilter)(context);
|
|
if (filter) {
|
|
return {
|
|
user: filter,
|
|
};
|
|
}
|
|
},
|
|
err: Exception_1.OakHasToVerifyPassword,
|
|
},
|
|
];
|
|
exports.default = checkers;
|