validateProps method

  1. @mustCallSuper
void validateProps(
  1. Map appliedProps
)

Throws a PropError if appliedProps are invalid.

This is called automatically with the latest props available during componentWillReceiveProps and componentWillMount, and can also be called manually for custom validation.

Override with a custom implementation to easily add validation (and don't forget to call super!)

@mustCallSuper
void validateProps(Map appliedProps) {
  super.validateProps(appliedProps);

  var tProps = typedPropsFactory(appliedProps);
  if (tProps.items.length.isOdd) {
    throw new PropError.value(tProps.items, 'items', 'must have an even number of items, because reasons');
  }
}

Implementation

@mustCallSuper
void validateProps(Map appliedProps) {
  validateRequiredProps(appliedProps);
}