|
|
@@ -1,5 +1,5 @@
|
|
|
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
|
|
-import Property from 'App/Models/Property'
|
|
|
+import Property, { PropertyType } from 'App/Models/Property'
|
|
|
import PaginationService from 'App/Services/PaginationService'
|
|
|
import { schema, rules } from '@ioc:Adonis/Core/Validator'
|
|
|
import { Exception } from '@adonisjs/core/build/standalone'
|
|
|
@@ -15,13 +15,10 @@ export default class PropertiesController {
|
|
|
await bouncer.authorize('admin')
|
|
|
const data = await request.validate({
|
|
|
schema: schema.create({
|
|
|
- id: schema.string({ trim: true }, [
|
|
|
- rules.regex(/^[a-zA-Z0-9_]+$/),
|
|
|
- rules.maxLength(72)
|
|
|
- ]),
|
|
|
name: schema.string(),
|
|
|
value: schema.string(),
|
|
|
- type: schema.string()
|
|
|
+ remark: schema.string(),
|
|
|
+ type: schema.enum(Object.values(PropertyType))
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -49,8 +46,9 @@ export default class PropertiesController {
|
|
|
const data = await request.validate({
|
|
|
schema: schema.create({
|
|
|
name: schema.string.optional([]),
|
|
|
+ remark: schema.string.optional(),
|
|
|
value: schema.string.optional(),
|
|
|
- type: schema.string.optional()
|
|
|
+ type: schema.enum(Object.values(PropertyType))
|
|
|
})
|
|
|
})
|
|
|
const property = await Property.findOrFail(params.id)
|