mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
Merge pull request #11028 from nestjs/chore/forbid-unknown-values-validation-pipe
chore(common): set forbid unknown values to false by default
This commit is contained in:
@@ -66,8 +66,10 @@ export class ValidationPipe implements PipeTransform<any> {
|
||||
...validatorOptions
|
||||
} = options;
|
||||
|
||||
// @see https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508
|
||||
this.validatorOptions = { forbidUnknownValues: false, ...validatorOptions };
|
||||
|
||||
this.isTransformEnabled = !!transform;
|
||||
this.validatorOptions = validatorOptions;
|
||||
this.transformOptions = transformOptions;
|
||||
this.isDetailedOutputDisabled = disableErrorMessages;
|
||||
this.validateCustomDecorators = validateCustomDecorators || false;
|
||||
|
||||
@@ -384,7 +384,7 @@ describe('ValidationPipe', () => {
|
||||
});
|
||||
describe('otherwise', () => {
|
||||
it('should not reject', async () => {
|
||||
target = new ValidationPipe({ forbidUnknownValues: false });
|
||||
target = new ValidationPipe();
|
||||
const testObj = [
|
||||
{ prop1: 'value1', prop2: 'value2', prop3: 'value3' },
|
||||
];
|
||||
@@ -447,7 +447,7 @@ describe('ValidationPipe', () => {
|
||||
target = new ValidationPipe({ expectedType: TestModel });
|
||||
const testObj = { prop1: 'value1', prop2: 'value2' };
|
||||
|
||||
expect(await target.transform(testObj, m)).to.equal(testObj);
|
||||
expect(await target.transform(testObj, m)).to.deep.equal(testObj);
|
||||
});
|
||||
|
||||
it('should validate against the expected type if presented and metatype is primitive type', async () => {
|
||||
@@ -460,7 +460,7 @@ describe('ValidationPipe', () => {
|
||||
target = new ValidationPipe({ expectedType: TestModel });
|
||||
const testObj = { prop1: 'value1', prop2: 'value2' };
|
||||
|
||||
expect(await target.transform(testObj, m)).to.equal(testObj);
|
||||
expect(await target.transform(testObj, m)).to.deep.equal(testObj);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user