Automattic\WooCommerce\Internal\PushNotifications\Validators
PushTokenValidator::validate_id
Validates ID.
Method of the class: PushTokenValidator{}
No Hooks.
Returns
true|false|WP_Error.
Usage
$result = PushTokenValidator::validate_id( $value, ?array $context );
- $value(mixed) (required)
- The value to validate.
- ?array $context
- .
Default:array()
Changelog
| Since 10.6.0 | Introduced. |
PushTokenValidator::validate_id() PushTokenValidator::validate id code WC 10.8.1
private static function validate_id( $value, ?array $context = array() ) {
if ( is_null( $value ) ) {
return new WP_Error( self::ERROR_CODE, 'ID is required.' );
}
if ( ! is_numeric( $value ) ) {
return new WP_Error( self::ERROR_CODE, 'ID must be numeric.' );
}
if ( $value <= 0 ) {
return new WP_Error( self::ERROR_CODE, 'ID must be a positive integer.' );
}
return true;
}