validate()

in django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js [205:231]


  validate(value = undefined) {
    let inputValue = typeof value != "undefined" ? value : this.value;
    let results = {};
    // Skip running validations when the input isn't shown
    if (!this.show) {
      return results;
    }
    let valueErrorMessages = [];
    if (this.isRequired && this.isEmpty(inputValue)) {
      if (this.type === DataType.URI_COLLECTION) {
        valueErrorMessages.push(IS_REQUIRED_URI_COLLECTION);
      } else {
        valueErrorMessages.push(IS_REQUIRED_DEFAULT);
      }
    }
    // Run through any validations if configured
    if (this.editorValidations.length > 0) {
      const validatorFactory = new ValidatorFactory();
      valueErrorMessages = valueErrorMessages.concat(
        validatorFactory.validate(this.editorValidations, inputValue)
      );
    }
    if (valueErrorMessages.length > 0) {
      results["value"] = valueErrorMessages;
    }
    return results;
  }