Skip to content
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

Array Validators & Transforms #29

Merged
merged 9 commits into from Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 62 additions & 0 deletions github-page/_docs/decorators/arrayProp.md
Expand Up @@ -61,6 +61,68 @@ class Another extends Typegoose {
}
```

### innerOptions

`innerOptions` is used to overwrite here the options in this object go
-> Use this only when absolutly needed and please open a new issue about it - or for plugins

Example:

```ts
class Something {
@arrayProp({ required: true })
public propy: string;
}

// This would be mapped to
{
type: [{ type: String }],
required: true
}

// when using the overwrite
class Something {
@arrayProp({ innerOptions: { required: true } })
public propy: string;
}

// This would be mapped to
{
type: [{ type: String, required: true }]
}
```

### outerOptions

`outerOptions` is used to overwrite here the options in this object go
-> Use this only when absolutly needed and please open a new issue about it - or for plugins

Example:

```ts
class Something {
@arrayProp({ maxlength: 1 })
public propy: string;
}

// This would be mapped to
{
type: [{ type: String, maxlength: 1 }]
}

// when using the overwrite
class Something {
@arrayProp({ outerOptions: { maxlength: 1 } })
public propy: string;
}

// This would be mapped to
{
type: [{ type: String }],
maxlength: 1
}
```

## Options from @prop that do **NOT** work on @arrayProp

- `ref` does not work, instead use `itemsRef` (please let us know if you are interested in combining them into one)
Expand Down
1 change: 1 addition & 0 deletions github-page/changelog.md
Expand Up @@ -18,6 +18,7 @@ redirect_from:
- `@prop({ validate })` now accepts `{ validator, message }` as an array
- Add function "deleteModel" & "deleteModelWithClass"
- allow Prop Option "type" to overwrite the inferred type [look here for an example](https://typegoose.github.io/typegoose/docs/decorators/prop/#type)
- integrate "Array Validators & Transform" tests {% include gitissue repo="typegoose" num=29 %}
- [IC] Refactor how "isPrimitive" works, some types like `Buffer` & `Decimal` now work
- [IC] Added more debug logs to `prop.ts`
- [IC] Move Decorator Cache to the class itself
Expand Down
141 changes: 116 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions package.json
Expand Up @@ -34,21 +34,22 @@
],
"license": "MIT",
"peerDependencies": {
"mongoose": "^5.7.4"
"mongoose": "^5.7.6"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^0.1.3",
"@types/chai": "^4.2.3",
"@types/chai-as-promised": "^7.1.2",
"@types/mocha": "^5.2.7",
"@types/mongoose": "^5.5.20",
"@types/mongoose": "^5.5.22",
"@types/node": "^8.10.53",
"@types/semver": "^6.0.2",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.0.6",
"mocha": "^6.2.1",
"coveralls": "^3.0.7",
"mocha": "^6.2.2",
"mongodb-memory-server-global": "^5.2.8",
"mongoose": "^5.7.4",
"mongoose": "^5.7.6",
"mongoose-findorcreate": "^3.0.0",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
Expand All @@ -62,7 +63,8 @@
},
"dependencies": {
"loglevel": "^1.6.4",
"reflect-metadata": "^0.1.13"
"reflect-metadata": "^0.1.13",
"semver": "^6.3.0"
},
"publishConfig": {
"access": "public"
Expand Down