示例#1
0
 this.resetToOriginal = function () {
   if (s.isBlank(_originalValue())) {
     this.edit();
   } else {
     _value(_originalValue());
     _canEdit(false);
   }
 };
示例#2
0
  this.validate = (entity, attr) => {
    if (s.isBlank(entity[attr]())) {
      return;
    }

    if (!entity[attr]().match(URL_REGEX)) {
      entity.errors().add(attr, Validatable.ErrorMessages.mustBeAUrl(attr));
    }
  };
示例#3
0
  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`));
    }
  };
示例#4
0
  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));
    }
  };
示例#5
0
  this.validate = (entity, attr) => {
    if (options.condition && (!options.condition(entity))) {
      return;
    }

    if (s.isBlank(entity[attr]())) {
      entity.errors().add(attr, Validatable.ErrorMessages.mustBePresent(attr));
    }
  };
示例#6
0
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');
};
示例#7
0
文件: parameters.js 项目: cv/gocd
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');
};
示例#8
0
文件: artifacts.js 项目: cv/gocd
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()));
    }
  });
};
示例#9
0
文件: pipeline.js 项目: cv/gocd
 this.isBlank = function () {
   return s.isBlank(this.spec()) && !this.onlyOnChanges();
 };
示例#10
0
 this.isBlank = function () {
   return s.isBlank(this.name()) && s.isBlank(this.value());
 };
示例#11
0
文件: artifacts.js 项目: cv/gocd
 this.isBlank = function () {
   return s.isBlank(this.source()) && s.isBlank(this.destination());
 };