Allow api to remove code from user with "0000" / Fix regex (only 0-9)
This commit is contained in:
parent
cd8d0bc497
commit
7693d793c0
@ -125,7 +125,7 @@ async function patch(req: Request, res: Response) {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
name: value.name,
|
name: value.name,
|
||||||
code: value.code
|
code: (value.code === '0000') ? null : value.code
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true
|
id: true
|
||||||
|
@ -22,7 +22,7 @@ const schema_get = validator
|
|||||||
// MARK: CREATE user
|
// MARK: CREATE user
|
||||||
const schema_post = validator.object({
|
const schema_post = validator.object({
|
||||||
name: validator.string().min(1).max(32).required(),
|
name: validator.string().min(1).max(32).required(),
|
||||||
code: validator.string().min(4).max(4).trim().regex(new RegExp('/^[0-9]+$/'))
|
code: validator.string().min(4).max(4).trim().regex(new RegExp(/^[0-9]+$/))
|
||||||
});
|
});
|
||||||
|
|
||||||
// MARK: UPDATE user
|
// MARK: UPDATE user
|
||||||
@ -30,7 +30,7 @@ const schema_patch = validator
|
|||||||
.object({
|
.object({
|
||||||
id: validator.number().positive().precision(0).required(),
|
id: validator.number().positive().precision(0).required(),
|
||||||
name: validator.string().min(1).max(32),
|
name: validator.string().min(1).max(32),
|
||||||
code: validator.string().min(4).max(4).trim().regex(new RegExp('/^[0-9]+$/'))
|
code: validator.string().min(4).max(4).trim().regex(new RegExp(/^[0-9]+$/))
|
||||||
})
|
})
|
||||||
.or('name', 'code');
|
.or('name', 'code');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user