public static function isValid($value)
    {
        if ($value instanceof ObjectID || $value instanceof MongoId) {
            return true;
        } elseif (! is_string($value)) {
            return false;
        }

        return (bool) preg_match('#^[a-f0-9]{24}$#i', $value);
    }
public static function isValid($value)
    {
        if ($value instanceof ObjectID || $value instanceof MongoId) {
            return true;
        } elseif (! is_string($value)) {
            return false;
        }

        return (bool) preg_match('#^[a-f0-9]{24}$#i', $value);
    }
public static function isValid ( $ value ) { if ( $ value instanceof ObjectID || $ value instanceof MongoId ) { return true ; } elseif ( ! is_string ( $ value ) ) { return false ; } return ( bool ) preg_match ( '#^[a-f0-9]{24}$#i' , $ value ) ; }
Check if a value is a valid ObjectId

@link http://php.net/manual/en/mongoid.isvalid.php
@param mixed $value The value to check for validity.
@return bool
Check if a value is a valid ObjectId