1
1
import { faker } from '@stacksjs/faker'
2
- import { validate } from '@stacksjs/validation'
2
+ import { validator } from '@stacksjs/validation'
3
3
import { defineModel } from '@stacksjs/config'
4
4
5
5
export default defineModel ( {
6
6
name : 'User' , // defaults to the sanitized file name
7
7
table : 'users' , // defaults to the lowercase, plural name of the model
8
-
8
+ // primaryKey: 'id', // defaults to `id`
9
+ // autoIncrement: true, // defaults to true
9
10
useUuid : true , // instead of `auto-incrementing id`, defaults to false
10
11
searchable : true , // defaults to false, also accepts SearchEngineSettings
11
12
seedable : { // defaults to a count of 10
@@ -17,7 +18,9 @@ export default defineModel({
17
18
fields : {
18
19
name : {
19
20
validator : {
20
- rule : validate . string ( ) . minLength ( 3 ) . maxLength ( 255 ) . nullable ( ) ,
21
+ // rule: validate.string('test').min(3).max(255),
22
+ rule : validator . string ( ) . minLength ( 3 ) . maxLength ( 255 ) ,
23
+ default : 'test' ,
21
24
message : 'Name must be between 3 and 255 characters' ,
22
25
} ,
23
26
@@ -26,7 +29,7 @@ export default defineModel({
26
29
27
30
status : {
28
31
validator : {
29
- rule : validate . enum ( [ 'active' , 'inactive' ] ) ,
32
+ rule : validator . enum ( [ 'active' , 'inactive' ] ) ,
30
33
message : 'Status must be either active or inactive' ,
31
34
} ,
32
35
@@ -37,7 +40,7 @@ export default defineModel({
37
40
unique : true ,
38
41
39
42
validator : {
40
- rule : validate . string ( ) . email ( ) ,
43
+ rule : validator . string ( ) . email ( ) ,
41
44
message : 'Email must be a valid email address' ,
42
45
} ,
43
46
@@ -46,7 +49,7 @@ export default defineModel({
46
49
47
50
password : {
48
51
validator : {
49
- rule : validate . string ( ) . minLength ( 6 ) . maxLength ( 255 ) ,
52
+ rule : validator . string ( ) . minLength ( 6 ) . maxLength ( 255 ) ,
50
53
message : 'Password must be between 6 and 255 characters' ,
51
54
} ,
52
55
0 commit comments