-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5d49508
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2021 j&s-soft GmbH | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# TS SerVal | ||
|
||
[](https://github.com/js-soft/ts-serval/actions?query=workflow%3APublish) | ||
[](https://www.npmjs.com/package/@js-soft/ts-serval) | ||
|
||
TS SerVal (**T**ype**S**cript **Ser**ialization and **Val**idation) is a TypeScript library for runtime serialization and validation of JSON objects to/from JavaScript classes. It is using TypeScript decorators (e.g. @serialize()) to mark classes and properties for serialization and validation. It heavily uses reflection and TypeScript decorators. | ||
|
||
## Documentation | ||
|
||
The documentation for this package is currently under construction. | ||
|
||
### Features | ||
|
||
#### JSONWrapper & JSONWrapperAsync | ||
|
||
If you require to set any JSON content to a Serializable property, you can use JSONWrapper or JSONWrapperAsync. They enable the (de-)serialization with `serialize()`, `toJSON()`, `from()` or `deserialize()` in a generic way. | ||
|
||
The wrappers store all content into a generic `value` property as JSON. This property is transparent, meaning that `value` won't appear in the serialized output. However, accessing the `value` is required while using the wrappers programmatically. | ||
|
||
The wrappers are automatically used if ts-serval encounters a property of type Serializable (=> JSONWrapper) or SerializableAsync (=> JSONWrapperAsync). | ||
|
||
#### Type `any` | ||
|
||
If you would like to allow any type (be it any object, boolean, string, number), set `{any:true}` within the @serialize() descriptor. This will disable most of the parsing and (de-)serialization logic. | ||
|
||
```typescript | ||
@validate() | ||
@serialize({any:true}) | ||
public content:any | ||
``` | ||
|
||
If you would also like to allow `null` values, use `{nullable:true}` within the @validate() descriptor. | ||
|
||
```typescript | ||
@validate({nullable:true}) | ||
@serialize({any:true}) | ||
public content:any | ||
``` | ||
|
||
## Contribute | ||
|
||
Currently contribution to this project is not possible. This will change soon. | ||
|
||
## License | ||
|
||
[MIT](LICENSE) |