2021-04-26 21:22:04 +03:00
|
|
|
import BaseValidator from './base';
|
|
|
|
import validator from 'validator';
|
|
|
|
|
|
|
|
export default BaseValidator.create({
|
|
|
|
properties: ['name'],
|
|
|
|
|
|
|
|
name(model) {
|
2021-05-10 16:48:30 +03:00
|
|
|
if (!model.name) {
|
|
|
|
model.errors.add('name', 'Please enter Name.');
|
2022-09-13 11:23:54 +03:00
|
|
|
model.hasValidated.addObject('name');
|
2021-05-10 16:48:30 +03:00
|
|
|
this.invalidate();
|
|
|
|
}
|
2021-04-26 21:22:04 +03:00
|
|
|
if (!validator.isLength(model.name || '', 0, 191)) {
|
|
|
|
model.errors.add('name', 'Name cannot be longer than 191 characters.');
|
2022-09-13 11:23:54 +03:00
|
|
|
model.hasValidated.addObject('name');
|
2021-04-26 21:22:04 +03:00
|
|
|
this.invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|