-
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 all commits
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), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Будет стандартное сообщение из валидаторов class-validator
Но если нужно какое-то кастомное сообщение, то по логике нужно такое добавлять к каждому валидатору из class-validator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А каким может быть решение, при котором сообщения об ошибках сохранятся в проектах, в которых люди стероиды обновят?