address的过期checker
This commit is contained in:
parent
47d27cc6b0
commit
2eac154a18
|
|
@ -1,39 +1,11 @@
|
|||
import { isMobile } from 'oak-domain/lib/utils/validator';
|
||||
import { OakInputIllegalException } from "oak-domain/lib/types";
|
||||
import { checkAttributesNotNull } from 'oak-domain/lib/utils/validator';
|
||||
const checkers = [
|
||||
{
|
||||
type: 'data',
|
||||
action: 'create',
|
||||
entity: 'address',
|
||||
checker: (data) => {
|
||||
if (data instanceof Array) {
|
||||
data.forEach(ele => {
|
||||
checkAttributesNotNull('address', ele, ['name', 'detail', 'phone' /* , 'areaId' */]);
|
||||
if (!isMobile(ele.phone)) {
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
checkAttributesNotNull('address', data, ['name', 'detail', 'phone' /* , 'areaId' */]);
|
||||
if (!isMobile(data.phone)) {
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'data',
|
||||
action: 'update',
|
||||
entity: 'address',
|
||||
checker: (data) => {
|
||||
if (data.name === '') {
|
||||
throw new OakInputIllegalException('address', ['name'], '姓名不可为空');
|
||||
}
|
||||
if (data.detail === '') {
|
||||
throw new OakInputIllegalException('address', ['name'], '详细地址不可为空');
|
||||
}
|
||||
if (data.hasOwnProperty('phone') && !isMobile(data.phone)) {
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { Style } from '../../../../types/Style';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../../oak-app-domain").EntityDict, keyof import("../../../../oak-app-domain").EntityDict, false, {
|
||||
style: Style;
|
||||
entity: "system" | "application" | "platform";
|
||||
entity: "application" | "system" | "platform";
|
||||
entityId: string;
|
||||
name: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
type?: ButtonProps['type'] | AmButtonProps['type'];
|
||||
executeText?: string | undefined;
|
||||
buttonProps?: (ButtonProps & {
|
||||
color?: "primary" | "success" | "warning" | "default" | "danger" | undefined;
|
||||
color?: "default" | "success" | "primary" | "warning" | "danger" | undefined;
|
||||
fill?: "none" | "solid" | "outline" | undefined;
|
||||
size?: "small" | "large" | "middle" | "mini" | undefined;
|
||||
block?: boolean | undefined;
|
||||
|
|
|
|||
|
|
@ -2,40 +2,12 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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 checkers = [
|
||||
{
|
||||
type: 'data',
|
||||
action: 'create',
|
||||
entity: 'address',
|
||||
checker: (data) => {
|
||||
if (data instanceof Array) {
|
||||
data.forEach(ele => {
|
||||
(0, validator_2.checkAttributesNotNull)('address', ele, ['name', 'detail', 'phone' /* , 'areaId' */]);
|
||||
if (!(0, validator_1.isMobile)(ele.phone)) {
|
||||
throw new types_1.OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
(0, validator_2.checkAttributesNotNull)('address', data, ['name', 'detail', 'phone' /* , 'areaId' */]);
|
||||
if (!(0, validator_1.isMobile)(data.phone)) {
|
||||
throw new types_1.OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'data',
|
||||
action: 'update',
|
||||
entity: 'address',
|
||||
checker: (data) => {
|
||||
if (data.name === '') {
|
||||
throw new types_1.OakInputIllegalException('address', ['name'], '姓名不可为空');
|
||||
}
|
||||
if (data.detail === '') {
|
||||
throw new types_1.OakInputIllegalException('address', ['name'], '详细地址不可为空');
|
||||
}
|
||||
if (data.hasOwnProperty('phone') && !(0, validator_1.isMobile)(data.phone)) {
|
||||
throw new types_1.OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,41 +6,11 @@ import { RuntimeCxt } from '../types/RuntimeCxt';
|
|||
|
||||
const checkers: Checker<EntityDict, 'address', RuntimeCxt> [] = [
|
||||
{
|
||||
type: 'data',
|
||||
action: 'create',
|
||||
entity: 'address',
|
||||
checker: (data) => {
|
||||
if (data instanceof Array) {
|
||||
data.forEach(
|
||||
ele => {
|
||||
checkAttributesNotNull('address', ele, ['name', 'detail', 'phone'/* , 'areaId' */]);
|
||||
if (!isMobile(ele.phone!)) {
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
checkAttributesNotNull('address', data, ['name', 'detail', 'phone'/* , 'areaId' */]);
|
||||
if (!isMobile(data.phone!)) {
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
type: 'data',
|
||||
action: 'update',
|
||||
entity: 'address',
|
||||
checker: (data: EntityDict['address']['Update']['data']) => {
|
||||
if (data.name === '') {
|
||||
throw new OakInputIllegalException('address', ['name'], '姓名不可为空');
|
||||
}
|
||||
if (data.detail === '') {
|
||||
throw new OakInputIllegalException('address', ['name'], '详细地址不可为空');
|
||||
}
|
||||
if (data.hasOwnProperty('phone') && !isMobile(data.phone!)) {
|
||||
checker: (data) => {
|
||||
if (data.hasOwnProperty('phone') && !isMobile((data as EntityDict['address']['Update']['data']).phone!)) {
|
||||
throw new OakInputIllegalException('address', ['phone'], '手机号非法');
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue