export interface ValidationProps {
  validations?: string[];
  [key: string]: any;
}

function withValidations(Component: React.ComponentType<any>) {
  return (props: ValidationProps) => {
    const validations = props.validations || [];
    return validations.length > 0 ? (
      <div>
        <Component {...props} />
        <div className="qo-validation">
          {validations.map((validation: string) => (
            <p key={validation.replaceAll(/\s/g,'')}>{validation}</p>
          ))}
        </div>
      </div>
    ) : (
      <Component {...props} />
    );
  };
}

export default withValidations;
