validateForUpdate method

String? validateForUpdate()

Validates this value before it is sent to a native SDK.

Implementation

String? validateForUpdate() {
  if (pages.isEmpty || pages.any((page) => page < 0)) {
    return 'Background pages must contain zero-based page indexes.';
  }
  if (opacity < 0 || opacity > 1) {
    return 'Background opacity must be between 0 and 1.';
  }
  if (scale <= 0) {
    return 'Background scale must be greater than zero.';
  }
  if (rotation < 0 || rotation > 360) {
    return 'Background rotation must be between 0 and 360.';
  }
  if (type == CPDFBackgroundType.color && color == null) {
    return 'A color background requires color.';
  }
  if (type == CPDFBackgroundType.image &&
      (imagePath == null || imagePath!.trim().isEmpty)) {
    return 'An image background requires imagePath.';
  }
  return null;
}