this.resetToOriginal = function () { if (s.isBlank(_originalValue())) { this.edit(); } else { _value(_originalValue()); _canEdit(false); } };
this.validate = (entity, attr) => { if (s.isBlank(entity[attr]())) { return; } if (!entity[attr]().match(URL_REGEX)) { entity.errors().add(attr, Validatable.ErrorMessages.mustBeAUrl(attr)); } };
this.validate = (entity, attr) => { if (s.isBlank(entity[attr]())) { return; } if (!entity[attr]().match(format)) { entity.errors().add(attr, message || (`${s.humanize(attr)} format is in valid`)); } };
this.validate = (entity, attr) => { if (_.isNil(entity.parent()) || s.isBlank(entity[attr]())) { return; } if (!entity.parent().isUnique(entity, attr)) { entity.errors().add(attr, Validatable.ErrorMessages.duplicate(attr)); } };
this.validate = (entity, attr) => { if (options.condition && (!options.condition(entity))) { return; } if (s.isBlank(entity[attr]())) { entity.errors().add(attr, Validatable.ErrorMessages.mustBePresent(attr)); } };
EnvironmentVariables.Variable = function (data) { this.constructor.modelType = 'environmentVariable'; Mixins.HasUUID.call(this); Validatable.call(this, data); this.parent = Mixins.GetterSetter(); this.name = Stream(s.defaultToIfBlank(data.name, '')); const _value = Stream(plainOrCipherValue(data)); Mixins.HasEncryptedAttribute.call(this, {attribute: _value, name: 'value'}); this.toJSON = function () { if (this.isPlainValue()) { return { name: this.name(), secure: false, value: this.value() }; } else { if (this.isDirtyValue()) { return { name: this.name(), secure: true, value: this.value() }; } else { return { name: this.name(), secure: true, encryptedValue: this.value() }; } } }; this.isBlank = function () { return s.isBlank(this.name()) && s.isBlank(this.value()); }; this.validatePresenceOf('name', { condition(property) { return (!s.isBlank(property.value())); } }); this.validateUniquenessOf('name'); };
Parameters.Parameter = function (data) { this.constructor.modelType = 'parameter'; Mixins.HasUUID.call(this); Validatable.call(this, data); this.parent = Mixins.GetterSetter(); this.name = Stream(s.defaultToIfBlank(data.name, '')); this.value = Stream(s.defaultToIfBlank(data.value, '')); this.isBlank = function () { return s.isBlank(this.name()) && s.isBlank(this.value()); }; this.validatePresenceOf('name', { condition(property) { return (!s.isBlank(property.value())); } }); this.validateUniquenessOf('name'); };
Artifacts.Artifact = function (data) { this.constructor.modelType = 'artifact'; Mixins.HasUUID.call(this); Validatable.call(this, data); this.parent = Mixins.GetterSetter(); this.type = Stream(s.defaultToIfBlank(data.type, 'build')); this.source = Stream(s.defaultToIfBlank(data.source, '')); this.destination = Stream(s.defaultToIfBlank(data.destination, '')); this.isBlank = function () { return s.isBlank(this.source()) && s.isBlank(this.destination()); }; this.validatePresenceOf('source', { condition(property) { return (!s.isBlank(property.destination())); } }); };
this.isBlank = function () { return s.isBlank(this.spec()) && !this.onlyOnChanges(); };
this.isBlank = function () { return s.isBlank(this.name()) && s.isBlank(this.value()); };
this.isBlank = function () { return s.isBlank(this.source()) && s.isBlank(this.destination()); };