File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,11 @@ export class VineObject<
97
97
}
98
98
99
99
constructor ( properties : Properties , options ?: FieldOptions , validations ?: Validation < any > [ ] ) {
100
+ if ( ! properties ) {
101
+ throw new Error (
102
+ 'Missing properties for "vine.object". Use an empty object if you do not want to validate any specific fields'
103
+ )
104
+ }
100
105
super ( options , validations )
101
106
this . #properties = properties
102
107
}
Original file line number Diff line number Diff line change @@ -11,6 +11,16 @@ import { test } from '@japa/runner'
11
11
import vine from '../../../index.js'
12
12
13
13
test . group ( 'VineObject | flat object' , ( ) => {
14
+ test ( 'fail to construct schema when object is instantiated without object' , async ( {
15
+ assert,
16
+ } ) => {
17
+ assert . throws (
18
+ // @ts -expect-error
19
+ ( ) => vine . object ( ) ,
20
+ 'Missing properties for "vine.object". Use an empty object if you do not want to validate any specific fields'
21
+ )
22
+ } )
23
+
14
24
test ( 'fail when value is not an object' , async ( { assert } ) => {
15
25
const schema = vine . object ( {
16
26
username : vine . string ( ) ,
You can’t perform that action at this time.
0 commit comments