Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza bonab committed Mar 14, 2021
1 parent 0280fee commit 67fc393
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,47 @@
# class-validator-is-compatible-with
IsCompatibleWith is a decorator for class-validator that checks if siblings are not exist on object.
# InCompatibleWith
InCompatibleWith is a decorator for class-validator that checks if siblings are not exist on object.

### Use case:

InCompatibleWith checks if other properties exist on an object or not.
In this case we want to have either `status` or `deleted` on the instance of class. If both exist it will complain.

```typescript
class UpdateUserDTO {
@IsString()
@IncompatibleWith(['deleted'])
readonly status: string;

@IsBoolean()
@IncompatibleWith(['status'])
readonly deleted: boolean;

@IsString()
readonly name: string;
}
```


### Invalid Object
```json
const obj = {
status: 'test',
deleted: true,
name: 'john',
};
```

### Valid Object
```json
const obj = {
deleted: true,
name: 'john',
};
```
Or
```json
const obj = {
status: 'test',
name: 'john',
};
```

0 comments on commit 67fc393

Please sign in to comment.