Skip to content

Commit

Permalink
docs: ✏️ add onlyId docs
Browse files Browse the repository at this point in the history
add onlyId documentation
  • Loading branch information
jhomarolo-vortx committed Nov 22, 2023
1 parent de458fd commit e37550d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ plan.plan.myId = '123'
plan.plan.monthlyCost = 500
plan.isValid({exceptIDs: true}) // true

plan.isValid() // true
plan.errors // { }

```


You can validate only id field validation using `isValid({onlyIDs: true})`. Example: Imagine that your entity you want to validate only the id because you should insert first the id.

```javascript

const Plan =
entity('Plan', {
...
myId: id(Number),
monthlyCost: field(Number),
})

const plan = new Plan()
plan.plan.myId = '123'
plan.plan.monthlyCost = 500
plan.isValid({onlyIDs: true}) // true

plan.isValid() // false
plan.errors // { myId: [ wrongType: 'Number' ] }

Expand Down

0 comments on commit e37550d

Please sign in to comment.