-
Notifications
You must be signed in to change notification settings - Fork 4
#93 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
#93 #33
Changes from 3 commits
0ef11e6
a0c128f
66afc27
f2d4d81
af0e8cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import {applyDecorators} from '@nestjs/common'; | ||
import {ArrayNotEmpty, ValidateIf} from 'class-validator'; | ||
import {isEmpty as _isEmpty, isBoolean as _isBoolean} from 'lodash'; | ||
import {isBoolean as _isBoolean} from 'lodash'; | ||
import {BaseField, getFieldOptions, getMetaPrimaryKey, IBaseFieldOptions} from './BaseField'; | ||
import {Transform, TRANSFORM_TYPE_FROM_DB, TRANSFORM_TYPE_TO_DB} from '../Transform'; | ||
import {getTableFromModel} from '../../base/ModelTableStorage'; | ||
|
@@ -54,17 +53,13 @@ export function RelationIdField(options: IRelationIdFieldOptions = {}) { | |
options.nullable = true; | ||
} | ||
|
||
const arrayNotEmptyMessage = options.isFieldValidConstraintMessage || 'Не должно быть пустым'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Я правильно понимаю что этот текст ошибки нигде не будет выводиться? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Да There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. То есть мы теряем часть бизнес-логики при таком изменении? Чем она будет замещаться? А если эта логика лишняя, то прошу пояснить почему именно. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Выше ответил + я не понимаю, почему свойство options.isFieldValidConstraintMessage отвечает именно за текст ошибки при пустом массиве и находится только в RelationIdField There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Думаю стоит найти ответ на этот вопрос, в чатах или на мите. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Получилось найти ответ на этот вопрос? |
||
|
||
return applyDecorators( | ||
...[ | ||
BaseField(options, { | ||
decoratorName: 'RelationIdField', | ||
appType: 'relationId', | ||
jsType: 'number', | ||
}), | ||
options.nullable && ValidateIf((object, value) => !_isEmpty(value)), | ||
options.isArray && !options.nullable && ArrayNotEmpty({message: arrayNotEmptyMessage}), | ||
Transform(relationTransformFromDb, TRANSFORM_TYPE_FROM_DB), | ||
Transform(relationTransformToDb, TRANSFORM_TYPE_TO_DB), | ||
].filter(Boolean), | ||
|
Uh oh!
There was an error while loading. Please reload this page.