ValidateParamAllowNull static method

void ValidateParamAllowNull(
  1. Object? param,
  2. String paramName
)
Validates parameter (and allows null value). The param. Name of the param.

Implementation

static void ValidateParamAllowNull(Object? param, String paramName) {
  if (param is ISelfValidate) {
    try {
      param.Validate();
    } on ServiceValidationException catch (ex, stacktrace) {
      throw new ArgumentException(
          "ValidationFailed($paramName)", ex, stacktrace);
    }
  }

  if (param is ServiceObject) {
    if (param.IsNew) {
      throw new ArgumentException("ObjectDoesNotHaveId($paramName)");
    }
  }
}