feat(client): add isWorker condition in hasBusinessType
This commit is contained in:
parent
da59a556ca
commit
c5b8280403
|
@ -55,13 +55,16 @@ module.exports = Self => {
|
||||||
with: /^[\w|.|-]+@[\w|-]+(\.[\w|-]+)*(,[\w|.|-]+@[\w|-]+(\.[\w|-]+)*)*$/
|
with: /^[\w|.|-]+@[\w|-]+(\.[\w|-]+)*(,[\w|.|-]+@[\w|-]+(\.[\w|-]+)*)*$/
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.validate('businessTypeFk', hasBusinessType, {
|
Self.validateAsync('businessTypeFk', hasBusinessType, {
|
||||||
message: `The type of business must be filled in basic data`
|
message: `The type of business must be filled in basic data`
|
||||||
});
|
});
|
||||||
|
|
||||||
function hasBusinessType(err) {
|
async function hasBusinessType(err, done) {
|
||||||
if (!this.businessTypeFk)
|
const isWorker = await Self.app.models.UserAccount.findById(this.id);
|
||||||
|
|
||||||
|
if (!this.businessTypeFk && !isWorker)
|
||||||
err();
|
err();
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
Self.validatesLengthOf('postcode', {
|
Self.validatesLengthOf('postcode', {
|
||||||
|
|
Loading…
Reference in New Issue