2021-06-21 11:34:33 +03:00
|
|
|
import BaseValidator from './base';
|
|
|
|
import {isBlank} from '@ember/utils';
|
|
|
|
|
|
|
|
export default BaseValidator.create({
|
2021-06-28 12:49:54 +03:00
|
|
|
properties: ['name'],
|
2021-06-21 11:34:33 +03:00
|
|
|
|
2021-06-28 12:49:54 +03:00
|
|
|
name(model) {
|
|
|
|
let name = model.get('name');
|
2021-06-21 11:34:33 +03:00
|
|
|
let hasValidated = model.get('hasValidated');
|
|
|
|
|
2021-06-28 12:49:54 +03:00
|
|
|
if (isBlank(name)) {
|
|
|
|
model.get('errors').add('name', 'You must specify a name');
|
2021-06-21 11:34:33 +03:00
|
|
|
this.invalidate();
|
|
|
|
}
|
|
|
|
|
2021-06-28 12:49:54 +03:00
|
|
|
hasValidated.addObject('name');
|
2021-06-21 11:34:33 +03:00
|
|
|
}
|
|
|
|
});
|