Included user-information in employee Model.
This commit is contained in:
@@ -38,15 +38,17 @@ export default class CreateEmployeeValidator {
|
||||
trim: true
|
||||
}),
|
||||
|
||||
shorthand: schema.string({
|
||||
shorthand: schema.string(
|
||||
{
|
||||
trim: true
|
||||
},
|
||||
[
|
||||
},
|
||||
[
|
||||
rules.unique({
|
||||
table: 'employees',
|
||||
column: 'shorthand',
|
||||
caseInsensitive: true,
|
||||
})
|
||||
]),
|
||||
]),
|
||||
|
||||
email: schema.string.optional({
|
||||
trim: true
|
||||
@@ -61,7 +63,40 @@ export default class CreateEmployeeValidator {
|
||||
|
||||
mobile: schema.string.optional(),
|
||||
|
||||
contractHours: schema.number.optional()
|
||||
contractHours: schema.number.optional(
|
||||
[
|
||||
rules.unsigned(),
|
||||
rules.range(0, 40)
|
||||
]
|
||||
),
|
||||
|
||||
role: schema.string(
|
||||
{
|
||||
trim: true
|
||||
}
|
||||
),
|
||||
|
||||
isActive: schema.boolean.optional(),
|
||||
|
||||
username: schema.string.optional(
|
||||
{
|
||||
trim: true
|
||||
},
|
||||
[
|
||||
rules.unique({
|
||||
table: 'employees',
|
||||
column: 'username',
|
||||
caseInsensitive: true,
|
||||
})
|
||||
]
|
||||
),
|
||||
|
||||
password: schema.string.optional(
|
||||
{},
|
||||
[
|
||||
rules.requiredIfExists('username')
|
||||
]
|
||||
)
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ export default class UpdateEmployeeValidator {
|
||||
rules.unique({
|
||||
table: 'employees',
|
||||
column: 'shorthand',
|
||||
caseInsensitive: true,
|
||||
whereNot: {
|
||||
id: this.ctx.params.id
|
||||
}
|
||||
@@ -64,7 +65,36 @@ export default class UpdateEmployeeValidator {
|
||||
|
||||
mobile: schema.string.optional(),
|
||||
|
||||
contractHours: schema.number.optional()
|
||||
contractHours: schema.number.optional([
|
||||
rules.unsigned(),
|
||||
rules.range(0, 40)
|
||||
]),
|
||||
|
||||
role: schema.string({
|
||||
trim: true
|
||||
}),
|
||||
|
||||
isActive: schema.boolean.optional(),
|
||||
|
||||
username: schema.string.optional(
|
||||
{
|
||||
trim: true
|
||||
},
|
||||
[
|
||||
rules.unique({
|
||||
table: 'employees',
|
||||
column: 'username',
|
||||
caseInsensitive: true,
|
||||
})
|
||||
]
|
||||
),
|
||||
|
||||
password: schema.string.optional(
|
||||
{},
|
||||
[
|
||||
rules.requiredIfExists('username')
|
||||
]
|
||||
)
|
||||
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user