diff --git a/es/checkers/address.js b/es/checkers/address.js index 45354c5af..53e13ef16 100644 --- a/es/checkers/address.js +++ b/es/checkers/address.js @@ -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'], '手机号非法'); } diff --git a/es/components/config/style/platform/index.d.ts b/es/components/config/style/platform/index.d.ts index 551c98f37..213a4c00f 100644 --- a/es/components/config/style/platform/index.d.ts +++ b/es/components/config/style/platform/index.d.ts @@ -2,7 +2,7 @@ import { Style } from '../../../../types/Style'; declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => import("react").ReactElement>; diff --git a/es/components/extraFile/commit/index.d.ts b/es/components/extraFile/commit/index.d.ts index 757f8ead6..566d5fcff 100644 --- a/es/components/extraFile/commit/index.d.ts +++ b/es/components/extraFile/commit/index.d.ts @@ -13,7 +13,7 @@ declare const _default: { - 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'], '手机号非法'); } diff --git a/src/checkers/address.ts b/src/checkers/address.ts index ee560ca94..3f9ac81d8 100644 --- a/src/checkers/address.ts +++ b/src/checkers/address.ts @@ -6,41 +6,11 @@ import { RuntimeCxt } from '../types/RuntimeCxt'; const checkers: Checker [] = [ { - 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;