57 if ( $value ===
'' ) {
58 return parent::validate( $value, $alldata );
65 if ( $this->mParams[
'exists'] && !(
66 $user->isRegistered() &&
68 !( $user->isHidden() && !( $this->mParent && $this->mParent->getUser()->isAllowed(
'hideuser' ) ) )
70 return $this->
msg(
'htmlform-user-not-exists', $user->getName() );
74 $excludeNamed = $this->mParams[
'excludenamed'] ??
null;
75 $excludeTemp = $this->mParams[
'excludetemp'] ??
null;
76 if ( ( $excludeTemp && $user->isTemp() ) || ( $excludeNamed && $user->isNamed() ) ) {
77 return $this->
msg(
'htmlform-user-not-valid', $user->getName() );
83 if ( $this->mParams[
'external'] && ExternalUserNames::isExternal( $value ) ) {
87 if ( $this->mParams[
'ipallowed'] ) {
88 $b = IPUtils::RE_IP_BYTE;
89 if ( IPUtils::isValid( $value ) ) {
91 } elseif ( $this->mParams[
'usemodwiki-ipallowed'] && preg_match(
"/^$b\.$b\.$b\.xxx$/", $value ) ) {
96 if ( $this->mParams[
'iprange'] ) {
98 if ( $rangeError ===
true ) {
100 } elseif ( $rangeError !==
false ) {
105 return $this->
msg(
'htmlform-user-not-valid', $value );
109 return parent::validate( $value, $alldata );
113 $cidrIPRanges = $this->mParams[
'iprangelimits'];
115 if ( !IPUtils::isValidRange( $value ) ) {
119 [ $ip, $range ] = explode(
'/', $value, 2 );
122 ( IPUtils::isIPv4( $ip ) && $cidrIPRanges[
'IPv4'] == 32 ) ||
123 ( IPUtils::isIPv6( $ip ) && $cidrIPRanges[
'IPv6'] == 128 )
126 return $this->
msg(
'ip_range_toolow' );
130 ( IPUtils::isIPv4( $ip ) && $range > 32 ) ||
131 ( IPUtils::isIPv6( $ip ) && $range > 128 )
134 return $this->
msg(
'ip_range_invalid' );
137 if ( IPUtils::isIPv4( $ip ) && $range < $cidrIPRanges[
'IPv4'] ) {
138 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv4'] );
141 if ( IPUtils::isIPv6( $ip ) && $range < $cidrIPRanges[
'IPv6'] ) {
142 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv6'] );