Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoenig134 committed Sep 24, 2021
0 parents commit 5d49508
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LICENSE
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.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# TS SerVal

[![GitHub Actions CI](https://github.com/js-soft/ts-serval/workflows/Publish/badge.svg)](https://github.com/js-soft/ts-serval/actions?query=workflow%3APublish)
[![npm version](https://badge.fury.io/js/@js-soft%2fts-serval.svg)](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)

0 comments on commit 5d49508

Please sign in to comment.