Merged PR 124: [PBI1221指摘対応]ライセンス注文APIの中で画面から渡ってきたパラメータのバリデーションを行う
## 概要 [Task1901: [PBI1221指摘対応]ライセンス注文APIの中で画面から渡ってきたパラメータのバリデーションを行う](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1901) - バリデーションチェック処理をコントローラに追加 - 未使用のimportを削除 - エラーテストで比較するメッセージが間違っていたので合わせて修正 ## レビューポイント - バリデーションのタイミングは適切か - バリデーションの範囲に過不足がないか ## UIの変更 - なし ## 動作確認状況 - ローカルで確認 ## 補足 - licenses.controller.ts以外もセルフチェックを行いました。
This commit is contained in:
parent
0ca766f309
commit
890b004a9c
@ -8,6 +8,7 @@ import {
|
||||
} from './test/liscense.service.mock';
|
||||
import { makeErrorResponse } from '../../common/error/makeErrorResponse';
|
||||
import { HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { PoNumberAlreadyExistError } from '../../repositories/licenses/licenses.repository.service';
|
||||
|
||||
describe('LicensesService', () => {
|
||||
it('ライセンス注文が完了する', async () => {
|
||||
@ -86,9 +87,7 @@ describe('LicensesService', () => {
|
||||
it('POナンバー重複時、エラーとなる', async () => {
|
||||
const lisencesRepositoryMockValue =
|
||||
makeDefaultLicensesRepositoryMockValue();
|
||||
lisencesRepositoryMockValue.order = new Error(
|
||||
'Email already verified user Error.',
|
||||
);
|
||||
lisencesRepositoryMockValue.order = new PoNumberAlreadyExistError();
|
||||
const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue();
|
||||
const accountsRepositoryMockValue =
|
||||
makeDefaultAccountsRepositoryMockValue();
|
||||
@ -105,7 +104,7 @@ describe('LicensesService', () => {
|
||||
service.licenseOrders(token, body.poNumber, body.orderCount),
|
||||
).rejects.toEqual(
|
||||
new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
makeErrorResponse('E010401'),
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
),
|
||||
);
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
|
||||
import { request } from 'http';
|
||||
import { makeErrorResponse } from '../../common/error/makeErrorResponse';
|
||||
import { CryptoService } from '../../gateways/crypto/crypto.service';
|
||||
import { AccessToken } from 'src/common/token';
|
||||
import { User as EntityUser } from '../../repositories/users/entity/user.entity';
|
||||
import {
|
||||
UsersRepositoryService,
|
||||
UserNotFoundError,
|
||||
@ -16,8 +13,6 @@ import {
|
||||
LicensesRepositoryService,
|
||||
PoNumberAlreadyExistError,
|
||||
} from '../../repositories/licenses/licenses.repository.service';
|
||||
import { CreateOrdersRequest } from './types/types';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class LicensesService {
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsInt, Matches, Max, Min } from 'class-validator';
|
||||
|
||||
export class CreateOrdersRequest {
|
||||
@ApiProperty()
|
||||
@Matches(/^[A-Z0-9]+$/)
|
||||
poNumber: string;
|
||||
|
||||
@ApiProperty()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(9999)
|
||||
orderCount: number;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user