47 if ( $value ===
null ) {
52 if ( $value ===
'' ) {
53 return parent::validate( $value, $alldata );
60 if ( $this->mParams[
'exists'] && !(
61 $user->isRegistered() &&
63 !( $user->isHidden() && !( $this->mParent && $this->mParent->getUser()->isAllowed(
'hideuser' ) ) )
65 return $this->
msg(
'htmlform-user-not-exists', $user->getName() );
71 if ( $this->mParams[
'external'] && ExternalUserNames::isExternal( $value ) ) {
75 if ( $this->mParams[
'ipallowed'] && IPUtils::isValid( $value ) ) {
79 if ( $this->mParams[
'iprange'] ) {
81 if ( $rangeError ===
true ) {
83 } elseif ( $rangeError !==
false ) {
88 return $this->
msg(
'htmlform-user-not-valid', $value );
92 return parent::validate( $value, $alldata );
96 $cidrIPRanges = $this->mParams[
'iprangelimits'];
98 if ( !IPUtils::isValidRange( $value ) ) {
102 [ $ip, $range ] = explode(
'/', $value, 2 );
105 ( IPUtils::isIPv4( $ip ) && $cidrIPRanges[
'IPv4'] == 32 ) ||
106 ( IPUtils::isIPv6( $ip ) && $cidrIPRanges[
'IPv6'] == 128 )
109 return $this->
msg(
'ip_range_toolow' );
113 ( IPUtils::isIPv4( $ip ) && $range > 32 ) ||
114 ( IPUtils::isIPv6( $ip ) && $range > 128 )
117 return $this->
msg(
'ip_range_invalid' );
120 if ( IPUtils::isIPv4( $ip ) && $range < $cidrIPRanges[
'IPv4'] ) {
121 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv4'] );
124 if ( IPUtils::isIPv6( $ip ) && $range < $cidrIPRanges[
'IPv6'] ) {
125 return $this->
msg(
'ip_range_exceeded', $cidrIPRanges[
'IPv6'] );